#!/bin/sh set -e # Generate main.cf from template with environment variables envsubst < /etc/postfix/main.cf.template > /etc/postfix/main.cf # Generate SASL password file from environment variables envsubst < /etc/postfix/sasl_passwd.template > /etc/postfix/sasl_passwd # Generate Postfix hash databases postmap /etc/postfix/sasl_passwd chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db # Regenerate sender_access database (in case of updates) postmap /etc/postfix/sender_access chmod 644 /etc/postfix/sender_access /etc/postfix/sender_access.db # Start Postfix in foreground exec postfix start-fg