I’m having difficulty getting the canonical_maps function to work as needed to repair some incorrect addresses from a legacy client. Here’s the situation and what I’ve tried so far:
Legacy client (oldhost.legacy.org) does not append its domain (legacy.org) to addresses in the envelope or the message when sending them via SMTP. So, if the user types an address such as guser@oldhost, it goes out with SMTP as user@oldhost instead of .
The machine with postfix (newhost.standard.org) has a different domain (standard.org) from the legacy machine. It also acts as MX and relay for the oldhost.legacy.org domain.
When messages from the legacy client arrive at the postfix machine with addresses such as guser@oldhost (missing .legacy.org), I’d like to rewrite those to read . It’s my understanding that the canonical_maps function is intended for this purpose.
In /etc/postfix/canonical.pcre I have:
/^(.*)@oldhost$/ $If I test with: postmap –qguser@oldhostpcre:/etc/postfix/canonical.pcre
the answer is: . Perfect.
In /etc/postfix/main.cf I have
canonical_maps = pcre:/etc/postfix/canonical.pcreThen, on the legacy host, I send a message such as:
To:
Cc: user@oldhostThe message arrives at the postfix machine, but the CC line is not rewritten.
The documentation for canonical_maps says that in order for the headers to be rewritten, the client needs to either match the local_header_rewrite_clients or else the remote_header_rewrite_domain must be non-null. I tried both but neither produces the output that I need.
If I set local_header_rewrite_clients = static:all or permit_mynetworks or some other option that would cause a match of the legacy client, then the append_dot_domain option takes over and rewrites the address as . The canonical table is apparently ignored.
If I instead leave local_header_rewrite_clients at its default (which does not match the legacy client) and turn on remote_header_rewrite_domain = invalid.domain, then the address is rewritten as and, once again, the canonical table is apparently ignored.
So the documentation for the canonical table is correct that rewriting only occurs if the local_header_rewrite_clients matches the client or if remote_header_rewrite_domain is set. And the rewrites are indeed occurring. But the rewriting that takes place completely ignores the canonical table.
So how do I get postfix to apply the append_dot_domain and append_at_myorigin only to itself and apply the canonical table to other clients or, at least apply the canonical table first?