On 18 Jul 2020, at 11:23, Stephan Bosch <stephan at rename-it.nl> wrote:> 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.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 at rename-it.nl> wrote: >> 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. > 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 at 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 at example.com, baz at example.com > cc: qux at 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.
<!doctype html> <html> <head> <meta charset="UTF-8"> </head> <body> <div> <br> </div> <blockquote type="cite"> <div> On 19/07/2020 15:49 @lbutlr <<a href="mailto:kremels@kreme.com">kremels@kreme.com</a>> wrote: </div> <div> <br> </div> <div> <br> </div> <blockquote type="cite"> <div> On 19 Jul 2020, at 04:58, @lbutlr <<a href="mailto:kremels@kreme.com">kremels@kreme.com</a>> wrote: </div> </blockquote> <div> [stuff] </div> <div> <br> </div> <div> I have this: </div> <div> <br> </div> <div> if address :is :localpart ["to", "cc"] "kremels" { </div> <div> if allof (address :count "ge" :comperator "i;ascii-numeric" ["to", "cc"] ["2"], </div> <div> not exists ["list-id","mailing-list", "x-loop"] ) </div> <div> { </div> <div> fileinto :create "listCC"; </div> <div> } </div> <div> } </div> <div> <br> </div> <div> I get: </div> <div> .active_sieve: line 55: error: unknown tagged argument ':comperator' for the address test (reported only once at first occurrence). </div> <div> .active_sieve: error: <a href="https://tools.ietf.org/html/rfc5231#section-6" rel="noopener" target="_blank"></a> </div> </blockquote> <div> :comparator might work better. </div> <div class="io-ox-signature"> <pre>--- Aki Tuomi</pre> </div> </body> </html>