Postfix Configure Multiple ISP Client SMTP Authentication

If you have multiple ISPs and want to use their respective SMTP servers for sending mail from your Postfix server, you can configure authentication for each ISP separately. Here’s how you can set up SMTP authentication for multiple ISPs in Postfix:

  1. Install the sasl2-bin package if it’s not already installed:
    sudo apt-get install sasl2-bin
  2. Create a new file in /etc/postfix/sasl directory for each ISP you want to use. For example, if you want to use two ISPs, create the following files:
    /etc/postfix/sasl/smtp1.conf
    /etc/postfix/sasl/smtp2.conf
  3. Add the following lines to each file, replacing SMTP_SERVER with the hostname or IP address of the ISP’s SMTP server, and USERNAME and PASSWORD with your authentication credentials:
    pwcheck_method: saslauthd
    mech_list: PLAIN LOGIN
    log_level: 7
    auth_mech: plain login
    SMTP_SERVER USERNAME:PASSWORD
  4. Make sure that the permissions on the new files are set correctly so that they can be read by the Postfix process:
    sudo chmod 600 /etc/postfix/sasl/smtp*.conf
  5. Edit the /etc/postfix/main.cf configuration file and add the following lines to set up SMTP authentication:
    # Enable SASL authentication
    smtp_sasl_auth_enable = yes
    # Path to the saslauthd socket
    smtp_sasl_path = smtpd
    # Set the authentication method
    smtp_sasl_security_options = noanonymous
    # Set the SASL configuration directory
    smtp_sasl_password_maps = hash:/etc/postfix/sasl/smtp1.conf, hash:/etc/postfix/sasl/smtp2.conf
  6. Save and close the main.cf configuration file, then restart the Postfix service:
    sudo systemctl restart postfix

With these configuration changes, your Postfix server should now be able to authenticate with the SMTP servers of each of your ISPs using the credentials you have provided in the corresponding smtp*.conf files.

Leave a Comment