I'm relaying emails for a bunch of domains to another server via the relay_domains configuration in main.cf:

File /etc/postfix/relaydomains:

domain1.com OK
domain2.com OK
domain3.com OK

Now I need to relay just a few addresses to another server:


All other should be forwarded as now. This means:

*@domains1.com -> server1
*@domains2.com -> server1
*@domains3.com -> server1
mail1@domain2.com -> server2 not server1
mail2@domain2.com -> server2 not server1

How can I do this? What is the proper way to do this?


You need to use postfix transport :

Set up /etc/postfix/transport as a transport map lookup table:

transport_maps = hash:/etc/postfix/transport

With the following content :

 domains1.com relay:[server1.example.com]
 domains2.com relay:[server1.example.com]
 domains3.com relay:[server1.example.com]
 mail1@domain2.com relay:[server2.example.com]
 mail2@domain2.com relay:[server2.example.com]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.