I've come across a situation in Postfix where it seems that my configuration is being ignored. I have a home network where the machines are named hostname.fakedomain, and a colo mail host with a real domain example.com. On my home machine, Postfix is configured to rewrite envelope addresses to use the real domain example.com, but to preserve the headers as-is. I keep this setup because I want mail to be delivered to my colo mail server, but I like preserving the headers so that I can see at a glance which machine on my home network sent which mail.
Relevant details:
- Arch Linux
- Postfix 2.7.2
-
/etc/postfix/canonical:
@hostname.fakedomain postmaster@example.com
-
"postconf -n" (partial output):
alias_database = $alias_maps alias_maps = hash:/etc/postfix/aliases canonical_classes = envelope_sender, envelope_recipient canonical_maps = hash:/etc/postfix/canonical mydestination = myhostname = hostname.fakedomain relay_domains = relayhost = example.com
Normally, this works just fine: local mail on my desktop is delivered to the postmaster account on my mail server, but the headers are not rewritten. However, if the mail as provided to the sendmail binary is missing the From: header, then the header is rewritten to From: root <postmaster@example.com>
. Since canonical_classes doesn't include "header_sender", this doesn't seem like it should happen. What I thought would happen is that Postfix would add From: root@hostname.fakedomain
. Also, I know that this is due to the canonical map, because if I change the address there to "otheraddress@example.com", the headers change as well.
One possible workaround would be to pipe each cron entry's output through /bin/mail, but I would prefer a Postfix configuration fix, so that this works for any mail that is missing a From: header, rather than just cron mail.
Is this actually a bug in Postfix, or am I misunderstanding how canonical_classes should work in this situation?
Best Answer
Might check these two: remote_header_rewrite_domain and local_header_rewrite_clients
The latter defaults to "permit_inet_interfaces" which, in the description of this other parameter, might give you the answer?
Even though the default is no, perhaps the local_header_rewrite_clients parameter not being empty is causing this.
However, I might also add the following (from the man page):
While what you're doing should work, perhaps using virtual/aliases would work better?
Oh, also just found that there are sender_canonical_classes and recipient_canonical_classes parameters as well. May want to check on those.