Want to send log files and stuff from servers on dynamic IP addresses? Here's how.
Add this to
/etc/postfix/main.cf, replacing the remote SMTP server:
relayhost = [smtp.example.com]:587 smtp_tls_security_level = encrypt smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
/etc/postfix/sasl_passwd with the following content, replacing the remote SMTP server, username and password:
Make it accessible by
chown root:root /etc/postfix/sasl_passwd chmod 0600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd to convert it into a Postfix-readable file.
Test that it works as expected:
echo "This is a test email body!" | mail -s "This is a Subject" -a "From: email@example.com" firstname.lastname@example.org
If there is trouble, make sure to check
/var/log/mail.log for hints.