Postfix : Relaying all incoming mail to another host
I have two hosts. One is mail1.example.com
and the other is mail2.example.com
. Each server has its own public IPv4 address, but they are in different geographical locations. Domain name has mail1
MX as mail server. I need to relay all incoming mail to mail2
.
I tried to implement a transport map by editing Postfix's main.cf
, but was not successful. What is the proper way to do this? What are the requirements for each server?
Solution 1:
You don't necessarily need transport map, though you could do it that way. Specifying relayhost = mail2
in main.cf should be all you need to get mail where it's wanted.
You also need to make sure that mail1 doesn't think it's the final destination system for any of the domains involved. ie put domains you deal with in relaydomains
, and definitely not in mydestination
.
There's a reasonably sophisticated example at http://www.postfix.org/STANDARD_CONFIGURATION_README.html#firewall which is likely to be appropriate, and which does use transport maps. It's concerned with avoiding relaying sub domains of the specified relaydomains, so may be overkill.
I would be a bit concerned that this sort of internal relaying substantially reduces your spam handling options. The internal host can't easily make decisions based on the remote IP, can't use greylisting, can't scrutinise whether the remote host waits for response lines from the host before sending the next mail command, etc. The gateway host likely doesn't have info on what accounts exist and so forth. If the gateway host accepts the email, and it turns out to be undeliverable, then you have to email your errors to the sending address, which is commonly referred to as "backscatter" (make sure you are familiar with the issues there).