Configure postfix to use smart host
My ISP filters outgoing SMTP traffic so to be able to run a mail server running at home I need to use the ISPs SMTP server to relay outgoing email. If they would have allowed open relaying from their customers I could just have set their SMTP server as ‘relayhost’ in /etc/postfix/main.cf and be done with it.
However, they require that I authenticate to their SMTP server which complicates matter slightly. This is how I did it:
- Create a password file, assigning username and password to SMTP relay hosts. Create the file /etc/postfix/relay_password and edit it to have the following content (replace the hostname with whatever relay host your ISP is providing and use your password and login)
smtp.bredband.net: - Change permissions for the credentials file and create a map file
# chown root:root /etc/postfix/relay_password
# chmod 600 /etc/postfix/relay_password
# postmap /etc/postfix/relay_password
- Update postfix configuration
relayhost = [smtp.bredband.net]
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/relay_password
- Restart postfix
# /etc/init.d/postfix restart
Mikael Vejdemo-Johansson
For some servers that only accept PLAIN and LOGIN authentications, this config above is not going to be enough, since postfix defaults to no plain-text authentications.
If your relay sending sessions terminate with
status=deferred (SASL authentication failed; cannot authenticate to server smtp.bredband.net[195.54.106.231]: no mechanism available)
then you’ll need to add the line
smtp_sasl_security_options =
to main.cf in order to turn off the noanonymous and noplaintext security options to SASL.