From version 2.3 onwards Postfix supports multiple accounts for sending mail. This can be useful in private or SOHO environments, when mailaccounts from different ISPs are used on the same postfix server.

In the following example, Postfix will look up the SASL file by sender for authentication then it will search the per-sender relayhost file for the relayhost to send the email depending on sender address.

# nano /etc/postfix/main.cf:
smtp_sender_dependent_authentication = yes
sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
relayhost = [mail.myisp.tld]

# nano /etc/postfix/sasl_passwd:
user1@example.com   username1:password1
user2@example.net   username2:password2

# nano /etc/postfix/sender_relay:
user1@example.com [mail.example.com]
user2@example.net [mail.example.net]

Don't forget to postmap these files after creating/editing

Previous Post Next Post