Using your ISP's SMTP server with postfix

by jenny on 01 December 2007 - 09:49pm in

Unlike esmtp, using your ISP's SMTP server with postfix will still allow local mail to be delivered. Any hosts listed in the mydestination option will be exempt from the SMTP relay.

Set up ISP info

Create /etc/postfix/sasl_passwd, like so:

mail.my-isp.org      username:password

Protect this file, since it has a plaintext password:

chown root.root /etc/postfix/sasl_passwd && chmod 600 /etc/postfix/sasl_passwd

Create sasl_passwd DB file

postmap hash:/etc/postfix/sasl_passwd

Tell Postfix about the new setup

In /etc/postfix/main.cf, change the relayhost option to your ISP's SMTP server:

relayhost = mail.my-isp.org

...and add these options:

# The following options allow relaying through the ISP's SMTP server
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =

Reload settings

/etc/init.d/postfix reload


Forcing a from address

If your ISP is retarded and uses sender authentication, you can force all mails sent through postfix to originate from an address they deem "valid". In /etc/postfix/main.cf, add:

smtp_generic_maps = hash:/etc/postfix/generic

In /etc/postfix/generic, put:

@localhost user@example.com

Tell postfix about the changes:

postmap /etc/postfix/generic
/etc/init.d/postfix restart

To debug what's going on, it's also helpful to look at the log:

# tail -n0 -f /var/log/mail.log