I am using postfix to manage email on a certain machine.
Some mail eventually gets relayed to a particular address, say nasty@example.com, and the mail server serving this address REQUIRES the envelope (MAIL FROM) field to be a particular value, say MAIL FROM james@bond.com.
How can I make postfix replace whatever it originally intended to have at this field by what I want?
The solutions which do not work:
smtp_generic_maps sets the sender address based on the original sender address, sender_canonical_maps does the same, except at a different point in the mail processing pipeline.
I need to change the Sender address based on the Recipient address. Headers must be left intact.
Nothing can be assumed about the message source. Can be local or external.