Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Before I clarify my question I need to explain the current setup.

We've got 1 Postfix server that can receive mail and store it in a mailbox. Some clients of ours have their own Exchange server, but we still provide a POP3 box on our Postfix server. The DNS of their domain is setup to first try to deliver mail to the Exchange server, if that one can't be reached deliver it to our Postfix server. If mail is being delivered to the Postfix server the mail gets stored inside a POP3 account. When the Exchange server is back online again it uses the POP-Locator to read the contents of the POP3 mailbox, download the mails and distribute them among the mailboxes on the Exchange server.

This all works very well. Because during an outage clients can still logon to our webmail and read important mail. This is a feature we'd like to keep.

The problem however is, that most clients also host their website on the same server that runs Postfix. When software running on that server tries to deliver mail to one of the clients email addresses it delivers it locally. What we want is Postfix to use MX lookup to see to which server the mail should be delivered.

For a long time now I've been trying to figure out to do this. I have the Postfix book and read through it. Looked up many configuration examples and other resources on the internet.

So far I've been trying to use transport_maps = hash:/etc/postfix/transport and list the specific domains in there, run postmap to regenerate the lookup tables and do a postfix reload. Whatever I try to do mail is being delivered locally.

To add some more context, we use Courier and have listed all domains in virtual_alias_maps = hash:/etc/postfix/virtual.

Any help would be much appreciated.


/etc/postfix/transport

example.com    smtp

/etc/postfix/virtual

example.com    postmaster
@example.com   someuseraccount
share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

The reason that you're finding it hard to do is that it is essentially impossible, because it contradicts the MTS model employed by Postfix. Mailboxes are either local or remote; they cannot be both. The local machine either is the final destination for the mail or it is not. Local and virtual domain address classes are "final destination", remote domain ("relay"/"default") address classes are not. The final destination for a single mailbox cannot be both a maildir on the local machine or a remote transport to some other machine. It has to be one or the other. A domain is either a local/hosted one, in which case mail for mailboxes in that domain is delivered to the local maildir to be picked up by POP3, or a remote one, in which case mail for mailboxes in that domain is transported to another machine and not delivered locally.

Your only real option is to run two separate MTSes — two distinct instances of Postfix. One provides SMTP Relay service to the Internet at large, and is configured with the domains in question as virtual domains, locally hosted, with all mail delivered to the maildir for subsequent retrieval via POP3. The other provides sendmail, postdrop, and the local SMTP Submission service, and is configured with the domains in question as relay domains, remotely hosted, whose mail is to be transported to the Exchange server.

Précis: Having two distinct and contradictory "paper paths" for mail requires having two MTS instances.

share|improve this answer
    
Thanks, this is a very clarifying answer. Which is basically what @Flimzy said, only more descriptive. –  Htbaa Jun 16 '11 at 12:51
add comment

Please show the contents of your /etc/postfix/transport file. It's impossible for me to tell if that file is correct or not.

Also, please clarify... Do you want postfix to attempt MX delivery for these domains, and only if it fails, then deliver locally?


Thanks for the additional info.

What you want to do is very tricky, and may not even be directly possible. I think the easiest way to accomplish this is to run two instances of postfix. See here http://www.postfix.org/MULTI_INSTANCE_README.html for detailed information.

You can configure one instance of postfix to accept mail from the world, and deliver to local mailboxes for POP3 retrieval, etc.

The other instance will accept mail from local processes, then attempt delivery via MX--possibly even to the first postfix instance.

In the second instance, you would disable the smtp service in master.cf, so that both instances aren't trying to listen to port 25. For all of the details, read the link above.

I hope this helps!

share|improve this answer
    
Edited my post. Must add to it that I also tried specifying IP-addresses, as well trying relay. If the Postfix server receives a message it's fine to deliver it locally (= situation where Exchange server is down). If a mail is being sent from the Postfix server (sendmail, php's mail()) then I want it to perform a MX lookup. Optionally it's fine if it tried local delivery afterwards if it can't deliver the e-mail. –  Htbaa Jun 16 '11 at 11:45
    
Thanks for your answer. The setup makes sense although it does indeed complicate stuff quite a lot. We're running Postfix 2.5.4 and it seems postmulti only exists since 2.6. I had already expected that the thing I want is tricky and it seems like all this is a bit much to avoid a 15-minute delay to wait for mail (POP-Locator can only check as early as every 15 minutes). I'll wait a bit more for other people to give a potential answer, otherwise I'll accept this one. –  Htbaa Jun 16 '11 at 12:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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