Sieve and handling multiple addresses
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@example.com => Direct
Message 2: to/cc foo@example.com & to/cc to anyone@anydomain.tlf => CC Optional: If it contains a specific header like "X-bypass: secret string" => no action
Message 3: NOT to/cc foo@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?
-- Was it everything you wanted to find? and did you miss me while you were looking for yourself out there?
@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@example.com => Direct
Message 2: to/cc foo@example.com & to/cc to anyone@anydomain.tlf => CC Optional: If it contains a specific header like "X-bypass: secret string" => no action
Message 3: NOT to/cc foo@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 ?
On 12 Jul 2020, at 10:17, Benny Pedersen <me@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@example.com => Direct Message 2: to/cc foo@example.com & to/cc to anyone@anydomain.tlf => CC Optional: If it contains a specific header like "X-bypass: secret string" => no action Message 3: NOT to/cc foo@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@ewxample.com AND to another unknown email.
-- 'I'm not a thief, madam. But if I were, I would be the kind that steals fire from the gods.' 'We've already got fire.' 'There must be an upgrade by now.'
On 12/07/2020 22:47, @lbutlr wrote:
On 12 Jul 2020, at 10:17, Benny Pedersen <me@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@example.com => Direct Message 2: to/cc foo@example.com & to/cc to anyone@anydomain.tlf => CC Optional: If it contains a specific header like "X-bypass: secret string" => no action Message 3: NOT to/cc foo@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@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.
On 18 Jul 2020, at 11:23, Stephan Bosch <stephan@rename-it.nl> wrote:
On 12/07/2020 22:47, @lbutlr wrote:
On 12 Jul 2020, at 10:17, Benny Pedersen <me@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@example.com => Direct Message 2: to/cc foo@example.com & to/cc to anyone@anydomain.tlf => CC Optional: If it contains a specific header like "X-bypass: secret string" => no action Message 3: NOT to/cc foo@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@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.
I'll look into that, thanks. (I don't often see doubled email addresses, in fact not sure I ever have, so that may be an edge case I can safely ignore).
This is what I have right now for testing. I assume there is at least on syntax error in here 😃
if address :is :localpart ["to", "cc"] "kremels" { if allof (address :count "ge" :comperator "i:ascii-numeric" ["to", "cc"] 2, (not exists ["list-id","mailing-list" "x-loop"] ) { fileinto :create "listCC" } }
So as I read this, if the list address is not in to or cc, then abort, otherwise, check if there is more than one address specified, AND there are no list headers, file it in a specific mailbox.
Not exactly what I want to do eventually, but enough for testing at this point.
-- Be careful what you wish for. You never know who will be listening. Or what, for that matter.
On 19/07/2020 12:58, @lbutlr wrote:
On 18 Jul 2020, at 11:23, Stephan Bosch <stephan@rename-it.nl> wrote:
On 12/07/2020 22:47, @lbutlr wrote:
On 12 Jul 2020, at 10:17, Benny Pedersen <me@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@example.com => Direct Message 2: to/cc foo@example.com & to/cc to anyone@anydomain.tlf => CC Optional: If it contains a specific header like "X-bypass: secret string" => no action Message 3: NOT to/cc foo@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@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. I'll look into that, thanks. (I don't often see doubled email addresses, in fact not sure I ever have, so that may be an edge case I can safely ignore).
This is what I have right now for testing. I assume there is at least on syntax error in here 😃
if address :is :localpart ["to", "cc"] "kremels" { if allof (address :count "ge" :comperator "i:ascii-numeric" ["to", "cc"] 2, (not exists ["list-id","mailing-list" "x-loop"] ) { fileinto :create "listCC" } }
So as I read this, if the list address is not in to or cc, then abort, otherwise, check if there is more than one address specified, AND there are no list headers, file it in a specific mailbox.
Not exactly what I want to do eventually, but enough for testing at this point.
Looks OK. Needs to be "2" though (argument is always string/string-list).
Regards,
Stephan.
On 19 Jul 2020, at 04:58, @lbutlr <kremels@kreme.com> wrote:
[stuff]
I have this:
if address :is :localpart ["to", "cc"] "kremels" { if allof (address :count "ge" :comperator "i;ascii-numeric" ["to", "cc"] ["2"], not exists ["list-id","mailing-list", "x-loop"] ) { fileinto :create "listCC"; } }
I get: .active_sieve: line 55: error: unknown tagged argument ':comperator' for the address test (reported only once at first occurrence). .active_sieve: error: validation failed.
<https://tools.ietf.org/html/rfc5231#section-6> says:
Using the message:
received: ... received: ... subject: example to: foo@example.com, baz@example.com cc: qux@example.com
The test:
address :count "ge" :comparator "i;ascii-numeric" ["to", "cc"] ["3"]
would evaluate to true,
Soooo… I'm a bit befuddled by this error as other Than the '3' the lines in the example are identical, right? Am I missing something?
-- Anyhoo, they hung me. Fen out bitches.
participants (5)
-
unknown@example.com
-
@lbutlr
-
Aki Tuomi
-
Benny Pedersen
-
Stephan Bosch