Erik Sørgaard
Erik Sørgaard

Reputation: 67

Broken syntax in Postfix header_checks

I`m setting up Postfix to edit the headers dependent on the reciever. This is done through header_checks(http://www.postfix.org/header_checks.5.html)

The logic is as follows: If the e-mail is sent to "[email protected]" then we copy the From field and an paste it to the Reply-To field, the From field is also set to "[email protected]".

I have no experience with regexp but through some searching I was able to come up with the following:

if /^To: ([email protected])\s.*$/
/^From: (.+@.+)\s.*$/ PREPEND Reply-To:$1
/^From: (.+@.+)\s.*$/ REPLACE From: [email protected]
endif

This does not work. I'm not sure what's wrong with the syntax, but any help would be very appreciated.

Regards Erik

Upvotes: 0

Views: 5289

Answers (2)

scythiang
scythiang

Reputation: 146

It looks like the accepted answer might mislead.

If you fight with if-endif in header_checks you should keep in mind the following:

If  the  input  string  matches /pattern/, then match that input
string against the patterns between if and endif.  The if..endif
can nest

from http://www.postfix.org/header_checks.5.html

Pay attention to "then match that input string". This means you can't operate any header inside the if/endif block but the one you use in if-statement.

Upvotes: 3

Fale
Fale

Reputation: 404

The problem is that the header_checks are applied only one time for each email line, so the seconf "From" line (line 3) is skipped.

Upvotes: 1

Related Questions