Configure Postfix

This these guides configure your postfix so its forwards all local mails to an external server using authentication.

Relay all Mail

This is the content of the entire /etc/postfix/ the servers name is the mail going out comes as instead of all mail is relayed to

inet_interfaces = loopback-only
myhostname =
mynetworks= [::1]/128
myorigin =
relayhost =
local_transport=error: local delivery disabled

Authenticate against relay

Install sasl to enable authentication.

[code language=”bash”]yum -y install postfix cyrus-sasl-plain mailx[/code]

Add the code below to /etc/postfix/

smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous

/etc/postfix/sasl_passwd is where username and password is stored

[code language=”bash”]echo "[]:587 myusername:secret" > nano /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
chown root:postfix /etc/postfix/sasl_passwd*
chmod 640 /etc/postfix/sasl_passwd
systemctl restart postfix[/code]


echo "Testing" | mail -s "Test Message 4"


If you get errors like the one below, it might be that you missed to install the package cyrus-sasl-plain

(delivery temporarily suspended: SASL authentication failed; cannot authenticate to server[]: no mechanism available)