Use remote relay with postfix
Published on .
Here’s how to configure postfix to use a remote mail relay
echo '* taylornet@nattaylor.com' > /etc/postfix/generic
echo '[hostname]:587 user:pass' > /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
sudo chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
vi /etc/postfix/main.cf
# Add this stuff
relayhost = [hostname]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
smtp_generic_maps = hash:/etc/postfix/generic
systemctl restart postfix
sendmail -t <<EOF
To: recipient@example.com
From: sender@example.com
Subject: Email Subject
This is the body of the email.
EOF
mailq
Hopefully this helps someone else too!