Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Postfix header_checks replace multiple occurrences inside References header

Writer Matthew Martinez

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: <[email protected]>

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

Message-Id: <[email protected]>

and gets replaced with:

Message-Id: <[email protected]>

How does this work with References Header?

Example Header:

References: <[email protected]> <[email protected]> <[email protected]>

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: <[email protected]>

(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?

1 Answer

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

Demo

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.