I’m trying to configure a sieve filter to forward emails to Gmail, and as per latest guidance from Google here I am trying to add the X-Forwarded-For and X-Forwarded-To headers to the redirected messages. The filter validates and looks OK, but these headers don’t appear in the forwarded messages.
Sieve filter details below. Note I’m trying to avoid forwarding messages with DMARC reject policy which Gmail doesn’t seem to like even with ARC validation and signing.
require "editheader";
if allof (
not header :contains "X-Spam-Flag" "YES",
not header :contains "ARC-Authentication-Results" "(policy=reject)"
)
{
addheader :last "X-Forwarded-For" "me@example.com";
addheader :last "X-Forwarded-To" "mygmailaddress@gmail.com";
redirect "mygmailaddress@gmail.com";
}
Doing some digging around, it looks like any X-Forward* headers are being removed by postfix smtp cleanup via this line in anonymize_headers.pcre:
/^\s*X-Forward/ IGNORE
I assume there must be a good reason for this behaviour, can anyone explain why it is configured this way? Is there an easy way to “whitelist” the X-Forwarded-For and X-Forwarded-To headers in anonymize_headers.pcre?