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 [email protected]

  • "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 <[email protected]>. 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: [email protected]. Also, I know that this is due to the canonical map, because if I change the address there to "[email protected]", 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?

1 Answer 1


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?

always_add_missing_headers (default: no):
   Always add (Resent-) From:, To:, Date: or Message-ID: headers when not
   present.  Postfix 2.6 and later add these headers only when clients
   match the local_header_rewrite_clients parameter setting.  Earlier
   Postfix versions always add these headers; this may break DKIM
   signatures that cover non-existent headers.**

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):

The canonical(5) mapping is not to be confused with virtual alias
support or with local aliasing. To change the destination but not the
headers, use the virtual(5) or aliases(5) map instead.**

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.

  • Hmm, apparently you can't format comments here, so I'll put in a separate comment for each point: Mar 3, 2011 at 4:58
  • sender_canonical_classes / recipient_canonical_classes: I tried them out and they unfortunately don't fix the problem. It turns out they only apply for the sender_canonical_maps and recipient_canonical_maps. Mar 3, 2011 at 4:59
  • remote_header_rewrite_domain / local_header_rewrite_clients: I actually do want it to add the missing headers, I just don't want canonical_maps to rewrite them. Mar 3, 2011 at 5:01
  • canonical vs. virtual vs. aliases maps: I had thought canonical maps was the recommended way to accomplish this, but after going over the documentation again, it seems you're correct. However, I'd still like to figure out whether or not this is the intended behavior for Postfix. Mar 3, 2011 at 5:04
  • One last comment: a friend also suggested that I use a lightweight SMTP agent such as ssmtp on my home machines. I think that's the best overall solution. Mar 3, 2011 at 5:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .