7

We currently have postfix handling emails generated by a number of apps. A number of these emails are destined for users inside the organisation, whose mail is on an Exchange server in the same site as the postfix box.

I'm looking for a way to do this, but my Google-fu is letting me down:

If the recipient domain is one of our domains, deliver the mail to host mail.example.com. All other mail is delivered by looking up the MX record/s and processing normally.

Edit: to clarify, the apps generating the emails are sending to users outside of our organisation too, postfix is not receiving mail at all.

  • http://www.postfix.org/transport.5.html looks promising – Vincent De Baere Jun 15 '11 at 8:59
  • I'm reading that right now. I also have a headache right now and I'm reasonably certain that's not a coincidence. :-) Was hoping someone had a quick answer that could save a bit of trial-and-error. – ThatGraemeGuy Jun 15 '11 at 9:08
  • Graeme, I know a quick and easy solution with exim: hubbed hosts. Regarding this matter, Postfix is somewhat more picky about who its friends are :) – Vincent De Baere Jun 15 '11 at 11:17
11

Instructions work for Ubuntu, you may need to adjust for other distros.

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

relay_domains = domain1.com, domain2.com
transport_maps = hash:/etc/postfix/transport
relay_recipient_maps = hash:/etc/postfix/relay_recipients
relay_transport = relay

Create the file /etc/postfix/transport:

domain1.com  smtp:[mail.example.com]
domain2.com  smtp:[mail.example.com]

Create the file /etc/postfix/relay_recipients:

@domain1.com x
@domain2.com x

Run these commands:

$ sudo postmap /etc/postfix/transport
$ sudo postmap /etc/postfix/relay_recipients
$ sudo /etc/init.d/postfix reload
| improve this answer | |
-1

Sounds like your postifx box is acting as a secondary MX (with Exchange as the primary). Just configure it as such.

| improve this answer | |
  • No it only relays mail, it doesn't receive. – ThatGraemeGuy Jun 15 '11 at 10:35
  • What is it relaying if it doesn't receive mails? Assuming you mean that it's not exposed on the network as a secondary MX, that doesn't matter (just skip the steps for the DNS config) – symcbean Jun 16 '11 at 12:30
  • It doesn't "receive" in the sense that it's not listed as the MX for anything. It receives mail from various app servers and delivers it to the destination. – ThatGraemeGuy Jun 17 '11 at 7:20
  • So its a secondary MX – symcbean Jun 22 '11 at 8:36

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.