We have a header_checks regexp passed to the "cleanup" process, but it's not processing the header as a single header if it's on multiple lines.
header_check (pass value of header to FILTER):
/^X-OurHeader:\s+(.*?)/ FILTER $1
master.cf:
cleanup_service. unix n - y - 0 cleanup
-o header_checks=regexp:/etc/postfix/header_check
Example multi-line header where it fails:
X-OurHeader: a_special_filter_command:my.sub.domain
b.mail.whatever.com
The original full header before getting multi-lined is:
X-OurHeader: a_special_filter_command:my.sub.domainb.mail.whatever.com
The result passed to FILTER is then: a_special_filter_command:my.sub.domain
and missing the remaining hostname from the second line b.mailwhatever.com
.
If I change the header_check to this instead, so it captures the next line:
/^X-OurHeader:\s+([\s\S]*)/ FILTER $1
The $1 capture group then contains the second line, but there's still a space (and presumably newline) in the captured text as well, so that doesn't work. That looks like this:
X-OurHeader: a_special_filter_command:my.sub.domain b.mail.whatever.com
Looking in the logs with the first approach, we see
postfix/cleanup[123456]: 27429A1FE8: filter: header X-OurHeader: a_special_filter_command:my.sub.domain? b.mail.whatever.com
Is there an alternative approach to this that anyone might suggest? The end goal is that we tag a header with a special cmd:hostname values that needs to be sent to the FILTER, but want to support that hdr value being broken up to multiple lines for a long header to meet the "length SHOULD be < 78" standard.