I have sender_dependent_default_transport_maps all set-up for virtual domains with their own IPs for outgoing mail - they work.

However when postfix's sendmail adds an email to the queue, apparently it still passes the email through the host domain and adds a header to the email !

Received: by hostname.blah

Before passing it onto the proper virtual hostname and IP for mailing out

(note the Return-Path and sender IP is all correct in the email)

Why is postfix so stupid and passes the email through the host server despite the sender transport map?

Do I have to find another MTA ?

Is there maybe another option I can use with its sendmail mta (I'm already using -f )

Another way of asking this is

Can postfix's sendmail change "received: by" based on sender envelope ?


Can I tell postfix's sendmail where the message is coming from on the command line?

It occurs to me if postfix listens on port 25 locally I might be able to initiate from the proper virtual host IP and it might figure this out. But that is overly complex.


Some clarification:

In case above, postfix is just a messenger. The source of the email was program who invoking postfix sendmail binary. One of responsibility of an email messenger was stamping every email with Received: header every time it received email. It documented in RFC 5231 Section "Received Lines in Gatewaying".

Now, when postfix sendmail binary adds an email to postfix queue, it put the email in maildrop binary without Received header. The one who put Received header was pickup daemon. When adding Received header, basically it tells us, "Hi, I have received email from sendmail binary userid xxx."

Your sender_dependent_default_transport_maps will be invoked when in routing stage. Postfix won't evaluate it when receiving stage.

Now the main question: Can we disable this behavior?

You can always manipulated postfix header using header_checks feature. Taken the idea from this post: Remove sensitive information from email headers with postfix, you can use this pcre line to remove the unwated header.

/^Received: by hostname.blah.*from userid/ IGNORE
  • I already tried header_checks to replace that line - it either is unwilling or unable to modify that particular header. It may be added out of sequence. Pretty sure I have to replace postfix with exim to get what I want or maybe a more simple MTA - I'm not arguing postfix shouldn't add that header, I'm saying it is pretty stupid to have advanced sender maps without considering how mail is put into the queue in the first place. – ck_ Sep 3 '15 at 10:24
  • update: your answer made me go back and try some more aggressive regex - and it worked - but instead of removing the line which breaks RFC rules, I replaced it with the proper hostname based on the userid (which I hope I never accidentally change) - thanks for the encouragement to try again – ck_ Sep 3 '15 at 10:37

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.