diff --git a/README.md b/README.md index 1e3cb74..b9a015f 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,9 @@ The following env variables need to be passed to the container: * `SMTP_PASSWORD` Password of the SMTP user. * `SERVER_HOSTNAME` Server hostname for the Postfix container. Emails will appear to come from the hostname's domain. +The following env variable(s) are optional. +* `SMTP_HEADER_TAG` This will add a header for tracking messages upstream. Helpful for spam filters. Will appear as "RelayTag: ${SMTP_HEADER_TAG}" in the email headers. + To use this container from anywhere, the 25 port or the one specified by `SMTP_PORT` needs to be exposed to the docker host server: docker run -d --name postfix -p "25:25" \ diff --git a/run.sh b/run.sh index aa1ff7d..9570d26 100644 --- a/run.sh +++ b/run.sh @@ -10,9 +10,7 @@ function add_config_value() { [ "${value}" == "" ] && echo "ERROR: No value set !!" && exit 1 echo "Setting configuration option ${key} with value: ${value}" - sed -i -e "/^#\?\(\s*${key}\s*=\s*\).*/{s//\1${value}/;:a;n;:ba;q}" \ - -e "\$a${key}=${value}" \ - ${config_file} + postconf -e "${key} = ${value}" } [ -z "${SMTP_SERVER}" ] && echo "SMTP_SERVER is not set" && exit 1 @@ -46,5 +44,12 @@ if [ ! -f /etc/postfix/sasl_passwd ]; then fi fi +#Set header tag +if [ ! -z "${SMTP_HEADER_TAG}" ]; then + postconf -e "header_checks = regexp:/etc/postfix/header_tag" + echo -e "/^MIME-Version:/i PREPEND RelayTag: $SMTP_HEADER_TAG\n/^Content-Transfer-Encoding:/i PREPEND RelayTag: $SMTP_HEADER_TAG" > /etc/postfix/header_tag + echo "Setting configuration option SMTP_HEADER_TAG with value: ${SMTP_HEADER_TAG}" +fi + #Start services supervisord