Open the main Postfix config file
vim /etc/postfix/main.cf
Add the following config
relayhost = [smtp.example.com]:465
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_CAfile = /etc/postfix/cacert.pem
smtp_use_tls = yes
smtp_tls_wrappermode = yes
smtp_tls_security_level = encrypt
Create a new file called sasl_passwd
to store the SMTP credentials
vim /etc/postfix/sasl_passwd
Add the SMTP server, port, username, and password
[smtp.example.com]:587 username:password
Create a hash database file for Postfix to read
postmap /etc/postfix/sasl_passwd
Modify the two file's permissions
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
chmod 0600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
Add a certificate for Postfix to use
cat /etc/ssl/certs/Digicert_Global_CA.pem | sudo tee -a /etc/postfix/cacert.pem