Setting up Postfix to use an external mail server

Sometimes sending mail to a dev account is all well and good, but if the mail server you are sending to is not accepting the mail for one reason or another (disallowed dynamic ip addresses, for instance) then you might need to set it up to send through a mail server (relay).

I am using as an example here, and the user “frank” with his password being “penguin” (clearly a very high security password)

Fire up terminal and sudo in.

sudo su
postconf -e ""
postconf -e "smtp_sasl_auth_enable=yes"
postconf -e "smtp_sasl_password_maps=hash:/etc/postfix/smtp_password"
echo " frank:penguin" > /etc/postfix/smtp_password
chmod 600 /etc/postfix/smtp_password
postmap /etc/postfix/smtp_password
service postfix restart