Skip to content

Instantly share code, notes, and snippets.

@fxi
Created February 15, 2016 14:31
Show Gist options
  • Save fxi/6d41f0e1cd7972a6e1d7 to your computer and use it in GitHub Desktop.
Save fxi/6d41f0e1cd7972a6e1d7 to your computer and use it in GitHub Desktop.
postfix config for vagrant ubuntu machine
if [[ ! -e $dirReceipts/postfix ]]
then
# doc found on
# https://www.linode.com/docs/email/postfix/postfix-smtp-debian7
# https://www.howtoforge.com/postfix_relaying_through_another_mailserver
export DEBIAN_FRONTEND=noninteractive
apt-get -qy purge mailutils postfix
apt-get install -qy postfix mailutils
# var
mailadmin="[email protected]"
mailfrom="[email protected]"
pwdmailfrom="mypassword"
relayhost="smtp.relay.com"
relayport=587
# postfix config
postconf -e "relayhost = [$relayhost]:$relayport"
postconf -e "smtp_sasl_auth_enable = yes"
postconf -e "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd"
postconf -e "smtp_sasl_security_options = noanonymous"
echo "$relayhost $mailfrom:$pwdmailfrom" | tee -a /etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
/etc/init.d/postfix restart
echo "postfix has been installed" | mail -s "provisioning" -a "From: $mailfrom" $mailadmin
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment