10

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.

3
  • 1
    http://www.postfix.org/transport.5.html looks promising Jun 15, 2011 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. Jun 15, 2011 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 :) Jun 15, 2011 at 11:17

2 Answers 2

15

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
2
-1

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

4
  • No it only relays mail, it doesn't receive. Jun 15, 2011 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, 2011 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. Jun 17, 2011 at 7:20
  • So its a secondary MX
    – symcbean
    Jun 22, 2011 at 8:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .