Postfix: mail delivered locally, but I wanted relayhost delivery

email-bouncespostfixsmtp

I work at example.net 🙂 and my team's server is named tardis.example.net . Any mail sent to us must first go through our company's internal relay hosts. Although the messages are delivered to our server correctly, the recipient address is rewritten from:

george@tardis.example.net

to:

george@example.net

As a result, our default Postfix (2.6.6) configuration refuses to deliver the message:

Nov 27 15:49:23 tardis postfix/qmgr[10564]: B6CC73FA22:
from=<someguy@example.net>, size=3953, nrcpt=1 (queue active)

Nov 27 15:49:24 tardis postfix/smtp[10580]: B6CC73FA22: to=<george@example.net>,
orig_to=<george@tardis.example.net>,
relay=outbound.example.net[172.30.113.194]:25,
delay=0.71, delays=0.47/0.01/0.14/0.1, dsn=5.1.1, status=bounced
(host outbound.example.net[172.30.113.194] said: 
550 5.1.1 <george@example.net>...  User unknown (in reply to RCPT TO command))

My solution to this was to change main.cf from this:

myhostname    = tardis.example.net
mydomain      = example.net
mydestination = $myhostname, localhost.$mydomain, localhost

to this:

myhostname    = tardis.example.net
mydomain      = example.net
mydestination = $myhostname, $mydomain, localhost.$mydomain, localhost

This works fine; by accepting mail for $mydomain, tardis.example.net now accepts incoming mail even with the recipient changed to george@example.net

The problem, however, is that all outgoing mail from our server to @example.net is now treated as local mail. Instead of being forwarded to $relayhost (outbound.example.net), Postfix attempts to deliver it to a local user on tardis.example.net .

How can I configure our server to accept incoming @example.net mail, but send ALL outgoing messages to $relayhost (with the possible exception of outgoing mail destined for @tardis.example.net, which is the only thing that should be delivered locally) ?

I looked through the FAQ on mail relaying and the various relay-related options in the documentation but could not find anything that would help me.

If you need further configuration info, I'll be happy to provide it. Thanks to anyone who can help.

Best Answer

Gah! Yes, you're right, Ismooth - I hadn't realized the difference between the to and orig_to line was coming from Postfix, not the upstream mail host. In this case, the standard distribution of Postfix loaded onto our server by the company contained the line:

masquerade_domains = example.net

which of course stripped off the "tardis" bit and turned george@tardis.example.net into george@example.net.

The solution was to remove that line, then remove $mydomain from the mydestination directive. Problem solved. Thanks for the help!