Postfix with single mail adresses – Send mails from your Linux server

This example covers three mail addresses using two different mail providers (provider1/2).

Configure Postfix

  • sudo dpkg-reconfigure postfix
  • Set configuration to “Internet with smart host”

main.cf

Add the following lines to /etc/postfix/main.cf:

sender_dependent_relayhost_maps = hash:/etc/postfix/relaymap
smtp_sender_dependent_authentication = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwords
smtp_sasl_security_options = noanonymous
canonical_maps = hash:/etc/postfix/canonical

Configure SMTP relay server from provider

Define the SMTP servers to send mail to. Only one entry for every provider domain is necessary.

Create /etc/postfix/relaymap

@provider1.org smtp-server.provider1.org
@provider2.org smtp-server.provider2.org

Create hash file:

sudo postmap /etc/postfix/relaymap

Configure email adresses sending configuration

Define mail addresses and their passwords to authenticate.

Create /etc/postfix/sasl_passwords

email1@provider1.org email1@provider1.org:PASSWORD
email2@provider1.org email2@provider1.org:PASSWORD
email3@provider2.org email3@provider2.org:PASSWORD

Create hash file:

sudo postmap /etc/postfix/sasl_passwords

Rewrite local addresses to global addresses for sending

Map your local user logins to global mail adresses.

Create /etc/postfix/canonical

root@yourpc.yourlocaldomain.xx email1@provider1.org
anotherlogin@yourpc.yourlocaldomain.xx email2@provider1.org
user3@yourpc.yourlocaldomain.xx email3@provider2.org

Create hash file:

sudo postmap /etc/postfix/canonical

Restart postfix

Leave a comment

Your email address will not be published.