0

I have a header_check that should match when the RECIPIENT address is domain.com and if it matches, then it changes the SENDER address to systems@service.domain.com

Scratching my head a little on this. Here is my header_check:

if /^To:(.*?)domain\.com/
/^From:(.*)/i REPLACE From: Systems <systems@service.domain.com>
endif

And here is an example header that I am testing against:

Date: Sat, 30 Jan 2021 16:25:31 +0000
Subject: Test Email
From: System <systems@domain.com>
To: IT.Devs.CMS@domain.com, IT.Devs.Transfer@domain.com,
 IT.Devs.FO@domain.com, it.connectivity@domain.com,

Truncated for readability. The first regex line matches when tested using a regex testing suite. The second line to actually match and replace works fine (i.e. if I use an inverse match then the replace works no problem).

Why on earth is the first line refusing to match? Thanks for any insight.

Postfix 3.1.0

HarryT
  • 13
  • 2

1 Answers1

0

I have found my problem, and it stems from a fundamental misunderstanding of how this works. The header_check only works on ONE (1) line at a time. In the above case, even if the IF line did match, the action line in the middle won't match, so nothing is done. Most regex tools use multiline by default. header_checks does not.

In short, header_checks only work for things that in a SINGLE line. If you want to match on one part and act on another, then header_checks is not how to do it.

Source: man header_checks bugs section

HarryT
  • 13
  • 2