Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I need to modify the "From:" header line in incoming e-mail messages only if "Message-Id:" starts with a defined string. So in main.cf I put:

header_checks = pcre:/etc/postfix/header_checks

and header_checks file contains:

if /^Message-Id: <footext.+/
/^From: (.*)@johndoe.com/ REPLACE From: ${1}@ext.johndoe.com
endif

It doesn't work, the condition does not take. What am I missing?

share|improve this question

1 Answer 1

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

if /pattern/flags

   endif  Match the input string against the patterns between
          if  and endif, if and only if ----> the same <----- input string
          also matches /pattern/. 

you can not use an if/endif block to match a different header.

share|improve this answer
    
So it seems header_checks is no good to my needs, isn't it? Can you suggest a way to have a conditional replace among header fields (matching a different header line)? Thanks in advance for any help you will offer. –  Gabriele Apr 14 '13 at 7:11
    
I'm not sure there is a simple way to do this with postfix internal features. For this kind of stuff, I usually attach a content filter like FuGlu (disclaimer: written by me) –  Gryphius Apr 15 '13 at 7:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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