5

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?

13

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).

| improve this answer | |
  • It works, but it does not relay emails from foreign domain names. Email get bounced with this error - 554 5.7.1 <name@mydomain.com>: Relay access denied? – M_R_K Oct 25 '14 at 1:59
  • Do you have the recipient's domain in relaydomains? – mc0e Oct 25 '14 at 5:10
  • Thanks that was it, but relayhost also relays my outgoing emails as well. I need to send outgoing mail strait from mail1 – M_R_K Oct 25 '14 at 6:35
  • 1
    You're getting a bit beyond the original question. The examples and documentation on the postfix site will serve you well, as what you are doing is very standard. – mc0e Oct 25 '14 at 10:27
  • Mail relaying is working fine now. Could you please answer my other question serverfault.com/questions/640306/… - Thanks – M_R_K Oct 28 '14 at 23:59

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.