Postfix setting reply-to field to sender

emailpostfixregular expressions

I would like to set the reply-to field to the sender of the mail if the recipient matches some addresses. I know I could do a regular expression like this to do this

/^(To|Cc):.*foo@bar.com/ PREPEND Reply-To: bla@example.com

But that would be static, is there a way to set the sender of the message?

Best Answer

According to http://www.postfix.org/header_checks.5.html you could use Perl Syntax for text replacement e.g.

/^(To|Cc):.*foo@bar.com/ PREPEND Reply-To: ${1}

The puzzle I've left to you is to look up the Perl RE Syntax to retrieve only the email as match.


Update: In your case it's this RegExp:

/^(To|Cc):\s*(\w+@\w+.\w{2,4})/ PREPEND Reply-To: ${2}

Related Topic