Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I work at :-) and my team's server is named . 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:


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=<>, size=3953, nrcpt=1 (queue active)

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

My solution to this was to change from this:

myhostname    =
mydomain      =
mydestination = $myhostname, localhost.$mydomain, localhost

to this:

myhostname    =
mydomain      =
mydestination = $myhostname, $mydomain, localhost.$mydomain, localhost

This works fine; by accepting mail for $mydomain, now accepts incoming mail even with the recipient changed to

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

How can I configure our server to accept incoming mail, but send ALL outgoing messages to $relayhost (with the possible exception of outgoing mail destined for, 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.

share|improve this question
It would have been better, I think, to fix the upstream mail server that was causing the original problem. – Michael Hampton Nov 27 '13 at 22:07
In this case is a very big company. The upstream mail administrators probably had some good reason to rewrite all addresses with a canonical, and won't particularly be interested in what our team would prefer. :-/ – George Adams Nov 27 '13 at 22:22
To me it looks like your postfix is changing the recipient and then tries to send that email back out, and their mail server says does not exist. Or am I missing something? – lsmooth Nov 27 '13 at 23:08

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 =

which of course stripped off the "tardis" bit and turned into

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

share|improve this answer
Don't forget to mark this answer as accepted – masegaloeh Mar 23 '15 at 15:54

Your Answer


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.