I'm trying to write (MTA-level) a Sieve filter that redirects certain emails to two different email addresses (that are both local to the mail server). It's an MTA-wide filter and looks like this:
require ["reject", "fileinto", "addheader", "copy", "relational", "comparator-i;ascii-numer
ic", "envelope"];
if allof (header :contains "From" "external@address",
header :contains "To" "me@msgsvr.internal")
{
redirect "sensitive@msgsvr.internal";
redirect "audit@msgsvr.internal"
}
else
{
keep;
}
When I install this filter, emails sent from external@address does get redirected to the sensitive and audit addresses but each of them receive about ten copies each of the email.
Not sure what's going on here but I suspect that redirecting to an internal address causes the email to run through the filter again and get redirected again, and again, and again until some loop-detection code inside Messaging Server trips.
I did a bit of a Google and found the following technique to work around this which involves adding headers to the email to ensure it is only filtered once:
if not exists "X-Sieve-filtered"
{
addheader "X-Sieve-filtered: processed" "processed";
redirect "sensitive@msgsvr.internal";
redirect "audit@msgsvr.internal"
stop;
}
else
{
addheader "X-Sieve-philtered: processed" "processed";
stop;
}
This doesn't work. I still get ten copies of the message, each having the X-Sieve-filtered header applied.
Can anyone help me out here. The Messaging Server docs are pretty light on the subject (they pretty much just refer you to the RFC for Sieve).