Image

Knowledge base → Postfix mail routing - Domain : MX

[Virtual servers]
Date of publication: 01.06.2023

Sometimes the task arises to configure mail routing for a specific domain to a specific MX server. For example, if you have several mail servers with the same domain, then in this guide we will configure the ability to specify for which domain which MX server to use to send mail.

1. Let's create a routing file with the following content:

nano /etc/postfix/transport

domain.tld smtp:mx.mail-server.tld

2. Connect the created file to the Postfix configuration:

/etc/postfix/main.cf
... transport_maps = hash:/etc/postfix/transport ...

2.1 Note: make sure the following options in the configuration file have the following setting:

...
# mydestination = $myhostname, localhost.localdomain, localhost
mydestination =
relayhost =
...

3. Apply settings:

postmap /etc/postfix/transport
postfix reload

Done, now all mail for the domain.tld domain will be sent to the mx.mail-server.tld mail server.





No Comments Yet