Sieve and handling multiple addresses

Stephan Bosch stephan at rename-it.nl
Sat Jul 18 20:23:31 EEST 2020



On 12/07/2020 22:47, @lbutlr wrote:
> On 12 Jul 2020, at 10:17, Benny Pedersen <me at junc.eu> wrote:
>> @lbutlr skrev den 2020-07-12 16:43:
>>> I an trying to write a sieve action that will take mail that is
>>> addressed to a user only it is filed in a mailbox (e.g. "Direct") if
>>> it is to the email AND to any other email address, then file it in a
>>> mailbox named, e.g. "Cc". And if the mail is not addressed to the user
>>> at all, sieve does nothing with it.
>>> Message 1: to foo at example.com => Direct
>>> Message 2: to/cc foo at example.com & to/cc to
>>> 	anyone at anydomain.tlf => CC
>>>    Optional: If it contains a specific header like
>>> 	"X-bypass: secret string" => no action
>>> Message 3: NOT to/cc foo at example.com => no action
>>> I've gotten exactly nowhere so far
>>> Something like
>>> if :allof (header :contains ["to"] ["foo#example.com"],
>>> 	header :contains ["cc"] ["foo#example.com"])
>>> Takes care of the first part of the message 1 and 2 criteria. But then what?
>> to, cc can be one single header test
>>
>> https://p5r.uk/blog/2011/sieve-tutorial.html
>>
>> allof will force all headers to match, and thus it will not always work if foo is not in both
>>
>> will this solve it ?
> That is helpful, but I still do not see how to test for "email has anndress other than this address". If I simply say the address does not contain the address, then to will not match any mail that is sent to both foo at ewxample.com AND to another unknown email.

Maybe you could use the ":count" match from the "relational" extension 
to check whether more than one address is contained in a header field 
when the recipient address is already present. This doesn't address the 
weird situation where the recipient address is listed more than once though.

Regards,

Stephan.


More information about the dovecot mailing list