feat: Parameterize destination config value

This commit is contained in:
nick 2021-06-30 05:05:26 -04:00 committed by Juan Luis Baptiste
parent 8011cddf8a
commit 222d3fad72
3 changed files with 7 additions and 2 deletions

View File

@ -28,3 +28,6 @@
# Optional: This will rewrite the from address overwriting it with the specified address for all email being relayed. # Optional: This will rewrite the from address overwriting it with the specified address for all email being relayed.
#OVERWRITE_FROM="Your Name" <email@company.com> #OVERWRITE_FROM="Your Name" <email@company.com>
# Optional: This will use allow you to set a custom $mydestination value. Default is localhost.
#DESTINATION=

View File

@ -77,6 +77,8 @@ The following env variable(s) are optional.
OVERWRITE_FROM=email@company.com OVERWRITE_FROM=email@company.com
OVERWRITE_FROM="Your Name" <email@company.com> OVERWRITE_FROM="Your Name" <email@company.com>
* `DESTINATION` This will define a list of domains from which incoming messages will be accepted.
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: 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" \ docker run -d --name postfix -p "25:25" \

4
run.sh
View File

@ -30,7 +30,7 @@ DOMAIN=`echo ${SERVER_HOSTNAME} | awk 'BEGIN{FS=OFS="."}{print $(NF-1),$NF}'`
add_config_value "maillog_file" "/dev/stdout" add_config_value "maillog_file" "/dev/stdout"
add_config_value "myhostname" ${SERVER_HOSTNAME} add_config_value "myhostname" ${SERVER_HOSTNAME}
add_config_value "mydomain" ${DOMAIN} add_config_value "mydomain" ${DOMAIN}
add_config_value "mydestination" 'localhost' add_config_value "mydestination" "${DESTINATION:-localhost}"
add_config_value "myorigin" '$mydomain' add_config_value "myorigin" '$mydomain'
add_config_value "relayhost" "[${SMTP_SERVER}]:${SMTP_PORT}" add_config_value "relayhost" "[${SMTP_SERVER}]:${SMTP_PORT}"
add_config_value "smtp_use_tls" "yes" add_config_value "smtp_use_tls" "yes"
@ -54,7 +54,7 @@ if [ ! -f /etc/postfix/sasl_passwd -a ! -z "${SMTP_USERNAME}" ]; then
grep -q "${SMTP_SERVER}" /etc/postfix/sasl_passwd > /dev/null 2>&1 grep -q "${SMTP_SERVER}" /etc/postfix/sasl_passwd > /dev/null 2>&1
if [ $? -gt 0 ]; then if [ $? -gt 0 ]; then
echo "Adding SASL authentication configuration" echo "Adding SASL authentication configuration"
echo "[${SMTP_SERVER}]:${SMTP_PORT} ${SMTP_USERNAME}:${SMTP_PASSWORD}" >> /etc/postfix/sasl_passwd echo "[${SMTP_SERVER}]:${SMTP_PORT} ${SMTP_USERNAME}@${DESTINATION:-localhost}:${SMTP_PASSWORD}" >> /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd postmap /etc/postfix/sasl_passwd
fi fi
fi fi