1

In postfix header_checks can be used to replace any header. This works for example perfectly for the Message-Id header.

Example:

/Message-Id:\s+<(.*?)@domain-a.com>/ REPLACE Message-Id: <$1@domain-b.com>

Any mail which is processed by postfix will be checked for the Header:

Message-Id: <example@domain-a.com>

and gets replaced with:

Message-Id: <example@domain-b.com>

How does this work with References Header?

Example Header:

References: <mail-1@domain-a.com> <mail-2@domain-a.com> <mail-3@domain-a.com>

Goal:

Replace any (1 - n) occurrence of domain-a.com with domain-b.com in this References header.

Try 1:

#/References:\s+<(.*?)@domain-a.com>/ REPLACE References: <$1@domain-b.com>

(works only with first occurence)

Try 2:

#/<.*?@(domain-a.com)>/ REPLACE domain-b.com

Does not work because header_checks need a valid Header name for the REPLACE command.

Can this replace achived with postfix native header_checks?

Linus
  • 41
  • 1
  • 4

1 Answers1

1

You can use (^References:|\G(?!\A)).*?@\Kdomain-a\.com with substitution domain-b.com

Demo

Michail
  • 843
  • 4
  • 11
  • Thank you very much! The regex is exactly what I'm searching for. Do you also know how the replacement works? /expression/ REPLACE References: <${n}@domain-b.com> will result in bad syntax. – Linus Oct 30 '22 at 09:28