I have a postfix installation where all addresses are virtually mapped to one user, i.e.:

>cat /etc/postfix/virtual
@mydomain.com myuser

What I want is the ability to reply to emails that are caught, and have those emails appear to come from the original sent address. So for example if amazon support sends me an email at amazon@mydomain.com and I want to reply, that reply currently is sent back as being from myuser@mydomain.com while I want it to appear to come from amazon@mydomain.com.

How can I get postfix to rewrite the outgoing address to match the original incoming address? I would ideally like to do this without creating an entirely new user on the system.


How can I get postfix to rewrite the outgoing address to match the original incoming address?

You can't. How would Postfix match outbound with inbound emails?

Instead, tell your email client to customize your reply's From: address. Some email clients (e.g. Thunderbird) let you associate multiple sender addresses with a single mailbox, which you can then select by clicking on the From field in your reply window. There may be email clients that are smart enough to make this selection automatically, based on To: or some other header in the mail you're replying to.

However it's handled, only your email client is able to make this connection...because you told it to create the reply.

  • I was hoping there was some chain of regex commands I could use to pass the X-Original-To field from the initial email on to the From: field of the reply. Or even just a regex to replace From: based on To:. Your solution is certainly simpler, though. – vityav Feb 12 '19 at 19:24
  • @vityav No client I know will copy non-canonical headers like X-Original-To into a reply, so Postfix won't see it anyway. – Adrian Feb 13 '19 at 2:57
  • @vityav As for blind rewriting of From: based on To:, I think that would require (1) header_checks rules to intercept and HOLD such messages, (2) trigger a script that extracts, rewrites, and resends these messages, and most importantly (3) somehow ensure that the new messages don't get trapped by (1) again. Not robust at all, and it's always-on...even when you don't want it to be. – Adrian Feb 13 '19 at 2:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.