1

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?

Gabriele
  • 351
  • 1
  • 4
  • 16

2 Answers2

2

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.

Gryphius
  • 2,760
  • 1
  • 20
  • 21
0

I came across this post and thought to update since I had a similar issue: I took a different approach using postfix pipe as suggested in some of these resources:

and just because I ran into the issue of loops:

SysadminB
  • 101
  • 1
  • 6