Commit 1dfce215 authored by Dariusz Janny's avatar Dariusz Janny
Browse files

[faas#36] faas-smtp - support for SMTP relay.

parent 334ed439
......@@ -38,8 +38,9 @@ RUN \
COPY ./conf/etc/supervisord.conf /etc/supervisord.conf
COPY ./conf/etc/entrypoint /etc/entrypoint
COPY ./conf/etc/aliases /etc/aliases
COPY ./conf/etc/postfix/master.cf /etc/postfix
EXPOSE 25/tcp
EXPOSE 25 587
ENTRYPOINT ["/etc/entrypoint"]
......@@ -3,6 +3,9 @@ config ?= conf/faas-smtp.cnf
include $(config)
export $(shell sed 's/=.*//' $(config))
credentials ?= conf/credentials/faas-smtp-default.cnf
include $(credentials)
export $(shell sed 's/=.*//' $(credentials))
.DEFAULT_GOAL := help
......@@ -13,10 +16,10 @@ build-nc: # build container without caching
docker build --no-cache -t ${FAAS_SMTP_IMAGE} --build-arg FAAS_SMTP_NAME=${FAAS_SMTP_NAME} --build-arg FAAS_SMTP_IMAGE=${FAAS_SMTP_IMAGE} --build-arg FAAS_SMTP_VERSION=${FAAS_SMTP_VERSION} .
run: # run container
docker run -i -t --detach --rm --env-file=$(config) -p=${FAAS_SMTP_PORT}:25 --name="${FAAS_SMTP_NAME}" ${FAAS_SMTP_IMAGE}
docker run -i -t --detach --rm --env-file=$(config) --env-file=$(credentials) -p=${FAAS_SMTP_PUBLIC_PORT}:587 --name="${FAAS_SMTP_NAME}" ${FAAS_SMTP_IMAGE}
run-nd: # run container in no-deamon mode
docker run -i -t --rm --env-file=$(config) -p=${FAAS_SMTP_PORT}:25 --name="${FAAS_SMTP_NAME}" ${FAAS_SMTP_IMAGE}
docker run -i -t --rm --env-file=$(config) --env-file=$(credentials) -p=${FAAS_SMTP_PUBLIC_PORT}:587 --name="${FAAS_SMTP_NAME}" ${FAAS_SMTP_IMAGE}
up: build run # build and run container
......
/faas-smtp-production.cnf
/faas-smtp-production.cnf
FAAS_SMTP_RELAY_SMTP_USERNAME=changeme
FAAS_SMTP_RELAY_SMTP_PASSWORD=changeme
......@@ -13,7 +13,6 @@ newaliases
sed -i '/imklog/s/^/#/' /etc/rsyslog.conf
function update_postfix_config_value() {
local key=${1}
local value=${2}
......@@ -21,10 +20,11 @@ function update_postfix_config_value() {
[ "${key}" == "" ] && echo "ERROR: Key is not set" && exit 1
[ "${value}" == "" ] && echo "ERROR:value is not set" && exit 1
echo "Setting configuration option ${key} with value: ${value}"
#echo "Setting configuration option ${key} with value: ${value}"
postconf -e "${key} = ${value}"
}
[ -z "${FAAS_SMTP_MYHOSTNAME}" ] && echo "FAAS_SMTP_MYHOSTNAME is not set" && exit 1
[ -z "${FAAS_SMTP_INET_INTERFACES}" ] && echo "FAAS_SMTP_INET_INTERFACES is not set" && exit 1
[ -z "${FAAS_SMTP_INET_PROTOCOLS}" ] && echo "FAAS_SMTP_INET_PROTOCOLS is not set" && exit 1
......@@ -34,6 +34,14 @@ update_postfix_config_value "inet_interfaces" ${FAAS_SMTP_INET_INTERFACES}
update_postfix_config_value "inet_protocols" ${FAAS_SMTP_INET_PROTOCOLS}
update_postfix_config_value "mynetworks" "${FAAS_SMTP_POSTFIX_MYNETWORKS}"
if [ "${FAAS_SMTP_RELAY}" = "yes" ]; then
echo "configure FAAS_SMTP_RELAY"
update_postfix_config_value "smtp_sasl_auth_enable" "${FAAS_SMTP_RELAY_SMTP_SASL_AUTH_ENABLE}"
update_postfix_config_value "smtp_sasl_security_options" "${FAAS_SMTP_RELAY_SMTP_SASL_SECURITY_OPTIONS}"
update_postfix_config_value "smtp_tls_security_level" "${FAAS_SMTP_RELAY_SMTP_TLS_SECURITY_LEVEL}"
update_postfix_config_value "relayhost" "${FAAS_SMTP_RELAY_SMTP_RELAYHOST}:${FAAS_SMTP_RELAY_SMTP_RELAYPORT}"
update_postfix_config_value "smtp_sasl_password_maps" "static:${FAAS_SMTP_RELAY_SMTP_USERNAME}:${FAAS_SMTP_RELAY_SMTP_PASSWORD}"
fi
rm -f /var/spool/postfix/pid/master.pid
rm -f /run/rsyslogd.pid
......
#
# Postfix master process configuration file. For details on the format
# of the file, see the master(5) manual page (command: "man 5 master" or
# on-line: http://www.postfix.org/master.5.html).
#
# Do not forget to execute "postfix reload" after editing this file.
#
# ==========================================================================
# service type private unpriv chroot wakeup maxproc command + args
# (yes) (yes) (no) (never) (100)
# ==========================================================================
smtp inet n - n - - smtpd
#smtp inet n - y - 1 postscreen
#smtpd pass - - y - - smtpd
#dnsblog unix - - y - 0 dnsblog
#tlsproxy unix - - y - 0 tlsproxy
submission inet n - n - - smtpd
# -o syslog_name=postfix/submission
# -o smtpd_tls_security_level=encrypt
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_tls_auth_only=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#smtps inet n - y - - smtpd
# -o syslog_name=postfix/smtps
# -o smtpd_tls_wrappermode=yes
# -o smtpd_sasl_auth_enable=yes
# -o smtpd_reject_unlisted_recipient=no
# -o smtpd_client_restrictions=$mua_client_restrictions
# -o smtpd_helo_restrictions=$mua_helo_restrictions
# -o smtpd_sender_restrictions=$mua_sender_restrictions
# -o smtpd_recipient_restrictions=
# -o smtpd_relay_restrictions=permit_sasl_authenticated,reject
# -o milter_macro_daemon_name=ORIGINATING
#628 inet n - y - - qmqpd
pickup unix n - y 60 1 pickup
cleanup unix n - y - 0 cleanup
qmgr unix n - n 300 1 qmgr
#qmgr unix n - n 300 1 oqmgr
tlsmgr unix - - y 1000? 1 tlsmgr
rewrite unix - - y - - trivial-rewrite
bounce unix - - y - 0 bounce
defer unix - - y - 0 bounce
trace unix - - y - 0 bounce
verify unix - - y - 1 verify
flush unix n - y 1000? 0 flush
proxymap unix - - n - - proxymap
proxywrite unix - - n - 1 proxymap
smtp unix - - y - - smtp
relay unix - - y - - smtp
-o syslog_name=postfix/$service_name
# -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq unix n - y - - showq
error unix - - y - - error
retry unix - - y - - error
discard unix - - y - - discard
local unix - n n - - local
virtual unix - n n - - virtual
lmtp unix - - y - - lmtp
anvil unix - - y - 1 anvil
scache unix - - y - 1 scache
postlog unix-dgram n - n - 1 postlogd
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent. See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
# Also specify in main.cf: maildrop_destination_recipient_limit=1
#
maildrop unix - n n - - pipe
flags=DRhu user=vmail argv=/usr/bin/maildrop -d ${recipient}
#
# ====================================================================
#
# Recent Cyrus versions can use the existing "lmtp" master.cf entry.
#
# Specify in cyrus.conf:
# lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4
#
# Specify in main.cf one or more of the following:
# mailbox_transport = lmtp:inet:localhost
# virtual_transport = lmtp:inet:localhost
#
# ====================================================================
#
# Cyrus 2.1.5 (Amos Gouaux)
# Also specify in main.cf: cyrus_destination_recipient_limit=1
#
#cyrus unix - n n - - pipe
# user=cyrus argv=/cyrus/bin/deliver -e -r ${sender} -m ${extension} ${user}
#
# ====================================================================
# Old example of delivery via Cyrus.
#
#old-cyrus unix - n n - - pipe
# flags=R user=cyrus argv=/cyrus/bin/deliver -e -m ${extension} ${user}
#
# ====================================================================
#
# See the Postfix UUCP_README file for configuration details.
#
uucp unix - n n - - pipe
flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient)
#
# Other external delivery methods.
#
ifmail unix - n n - - pipe
flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient)
bsmtp unix - n n - - pipe
flags=Fq. user=bsmtp argv=/usr/lib/bsmtp/bsmtp -t$nexthop -f$sender $recipient
scalemail-backend unix - n n - 2 pipe
flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store ${nexthop} ${user} ${extension}
mailman unix - n n - - pipe
flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py
${nexthop} ${user}
......@@ -3,11 +3,18 @@ FAAS_SMTP_NAME=faas-smtp
FAAS_SMTP_VERSION=1.0-SNAPSHOT
FAAS_SMTP_IMAGE=${FAAS_SMTP_REPO}/${FAAS_SMTP_NAME}:${FAAS_SMTP_VERSION}
FAAS_SMTP_MYHOSTNAME=test.faas.geant.net
FAAS_SMTP_INET_INTERFACES=all
FAAS_SMTP_INET_PROTOCOLS=all
FAAS_SMTP_POSTFIX_MYNETWORKS=127.0.0.1/32 192.168.0.0/16 172.16.0.0/12 172.17.0.0/16 10.0.0.0/8
FAAS_SMTP_PORT=9025
FAAS_SMTP_PUBLIC_PORT=9025
FAAS_SMTP_ROOT_ALIASES_LIST=janny@man.poznan.pl
FAAS_SMTP_POSTFIX_MYNETWORKS=127.0.0.1/32 192.168.0.0/16 172.16.0.0/12 172.17.0.0/16 10.0.0.0/8
\ No newline at end of file
FAAS_SMTP_MYHOSTNAME=changeme
FAAS_SMTP_ROOT_ALIASES_LIST=changeme@changeme
FAAS_SMTP_RELAY=[no|yes]
FAAS_SMTP_RELAY_SMTP_SASL_AUTH_ENABLE=yes
FAAS_SMTP_RELAY_SMTP_SASL_SECURITY_OPTIONS=noanonymous
FAAS_SMTP_RELAY_SMTP_TLS_SECURITY_LEVEL=encrypt
FAAS_SMTP_RELAY_SMTP_RELAYHOST=
FAAS_SMTP_RELAY_SMTP_RELAYPORT=
......@@ -11,7 +11,7 @@ my $smtppassword = '';
#my $to = 'janny@man.poznan.pl';
my $to = 'dariusz.janny@gmail.com';
my $from = 'root@test.faas.geant.net';
my $from = 'janny@man.poznan.pl';
my $subject = 'subject no 2';
my $smtp = Net::SMTP->new($smtpserver, Port=>$smtpport, Timeout => 10, Debug => 1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment