diff --git a/postfix/Dockerfile b/postfix/Dockerfile index d97f45b..430e259 100644 --- a/postfix/Dockerfile +++ b/postfix/Dockerfile @@ -2,6 +2,7 @@ FROM alpine:edge RUN apk add --no-cache \ bash \ + ca-certificates \ libsasl \ postfix \ rsyslog \ diff --git a/postfix/service/postfix/run b/postfix/service/postfix/run index b99e082..eddc9e8 100755 --- a/postfix/service/postfix/run +++ b/postfix/service/postfix/run @@ -1,44 +1,44 @@ #!/bin/bash set -e +# Avoid warning: smtputf8_enable is true, but EAI support is not compiled in +echo "smtputf8_enable = no" >> /etc/postfix/main.cf + # Do we want to modify the config first with the script? [ -f /etc/service/postfix/run.config ] && source /etc/service/postfix/run.config -if [ "$MAILNAME" ]; then +if [[ ! -z "$MAILNAME" ]]; then echo "$MAILNAME" > /etc/mailname postconf -e myhostname="$MAILNAME" fi -if [ "$MY_NETWORKS" ]; then +if [[ ! -z "$MY_NETWORKS" ]]; then postconf -e mynetworks="$MY_NETWORKS" fi -if [ "$MY_DESTINATION" ]; then +if [[ ! -z "$MY_DESTINATION" ]]; then postconf -e mydestination="$MY_DESTINATION" fi -if [ "$ROOT_ALIAS" ]; then - sed -i '/^root:/d' /etc/aliases +if [[ ! -z "$ROOT_ALIAS" ]]; then + if [[ -f /etc/aliases ]]; then + sed -i '/^root:/d' /etc/aliases + fi echo "root: $ROOT_ALIAS" >> /etc/aliases newaliases fi -if [ "$RELAY" ]; then +if [[ ! -z "$RELAY" ]]; then # setup the relay echo "relay_host = $RELAY" >> /etc/postfix/main.cf fi -if [ "$SASL_AUTH" ]; then +if [[ ! -z "$SASL_AUTH" ]]; then # setup tls - echo -e "smtp_sasl_auth_enable = yes\nsmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd\nsmtp_sasl_security_options = noanonymous\nsmtp_use_tls = yes" >> /etc/postfix/main.cf - - # Avoid warning: smtputf8_enable is true, but EAI support is not compiled in - echo "smtputf8_enable = no" >> /etc/postfix/main.cf + echo -e "smtp_sasl_auth_enable = yes\nsmtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd\nsmtp_sasl_security_options = noanonymous\nsmtp_use_tls = yes\ninet_interfaces = 127.0.0.1" >> /etc/postfix/main.cf # generate the SASL password map - cat > /etc/postfix/sasl_passwd <<- EOF - $RELAY $SASL_AUTH - EOF + echo "$RELAY $SASL_AUTH" > /etc/postfix/sasl_passwd # generate a .db file postmap /etc/postfix/sasl_passwd