I have a situation where emails sent to [email protected] are configured to go to a listserver via virtual_alias_maps:
virtual_alias_maps = $virtual_maps hash:/Library/Server/Mail/Data/listserver/aliases/list_server_virtual
I also have emails to [email protected] go there as well, but the listserver sucks (I'm stuck with it), and refuses to accept anything that isn't addressed to domain1.com. So, I thought rewriting might be the solution. Unfortunately, I'm not sure that rewriting ACTUALLY rewrites the To: header, which is what I was expecting and what I need to occur (I'm assuming my expectations are flawed).
So, I added:
recipient_canonical_maps = hash:/Library/Server/Mail/Config/postfix/canonical
And /Library/Server/Mail/Config/postfix/canonical contains:
[email protected] [email protected]
Now, emails sent to [email protected] are getting redirected ("rewritten"?) to [email protected], but when the email comes through, it still says "To: [email protected]".
So, to make things easier to troubleshoot, I updated canonical to rewrite [email protected] to come straight to me (bypassing any potential listserver confusion):
[email protected] [email protected]
But again, when emails are sent to: [email protected], they are correctly delivered to [email protected], but the headers still show "To: [email protected]"
Is there any way to get Postfix to literally rewrite the 'To:' header?
Modifying headers is not recommended and Postfix has abandoned it for reasons explained in Postfix Address Rewriting:
It's possible to change this behavior for canonical address mapping:
Also notice that if the headers are DKIM signed, DKIM will fail if tested after rewriting the headers. That's one practical reason why this might not be a good idea.