Categories
Computers Linux

Configure postfix to use smart host

This post shows how to configure Postfix to use a smart host with authentication.

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:

  1. 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 :
  2. 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
  3. Update postfix configuration

    relayhost = [smtp.bredband.net]
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = hash:/etc/postfix/relay_password
  4. Restart postfix

    # /etc/init.d/postfix restart
css.php