Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save talarczykco/62fe53568549c374751d1184f067df8f to your computer and use it in GitHub Desktop.

Select an option

Save talarczykco/62fe53568549c374751d1184f067df8f to your computer and use it in GitHub Desktop.
Relay Postfix through Amazon WorkMail

Amazon WorkMail

From Setting up IMAP for Amazon WorkMail:

Configuration Value
Protocol SMTPS (SMTP, encrypted with TLS) - not STARTTLS!
Port 465
Username Amazon WorkMail account
Password Amazon WorkMail password
Outgoing Server smtp.mail.us-east-1.awsapps.com

/etc/postfix/sasl_passwd

# create if needed
sudo vim /etc/postfix/sasl_passwd

# add username/password
[smtp.mail.us-east-1.awsapps.com]:465 [email protected]:CHANGEME

# lock down credentials
chmod 600 /etc/postfix/sasl_passwd

# update hash map - run after every change!
sudo postmap /etc/postfix/sasl_passwd

# reload
sudo postfix reload

postconf

# configure
sudo postconf relayhost='[smtp.mail.us-east-1.awsapps.com]:465'
sudo postconf smtp_sasl_auth_enable=yes
sudo postconf smtp_sasl_mechanism_filter=plain
sudo postconf smtp_sasl_password_maps=hash:/etc/postfix/sasl_passwd
sudo postconf smtp_tls_security_level=encrypt
sudo postconf smtp_tls_wrappermode=yes
sudo postconf smtp_use_tls=yes
sudo postfix reload

# send email
echo `date` | mail [email protected]

# check queue, it should be empty
mailq

Troubleshooting

# check queue, more -v's give more output
mailq -v

# manually run (flush) queue
sudo postqueue -f

# delete all messages in queue
sudo postsuper -d ALL

# on Mac, check logs (run this, then run mail commands again, in another window)
log stream --predicate  '(process == "smtpd") || (process == "smtp")' --info

See Also

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment