How to Set Up an SMTP Relay for Reliable Email Delivery
Using an SMTP Relay (Recommended for Transactional Email)
For reliable email delivery, consider using an SMTP relay service instead of sending directly.
Configure Postfix to Relay
Add to /etc/postfix/main.cf:
relayhost = [smtp.provider.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
Create credentials file:
echo "[smtp.provider.com]:587 username:password" > /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd
systemctl restart postfix