Yanko Hernández Álvarez
2013-Nov-14 18:17 UTC
[Dovecot] Sieve script problem (don't know if is it possible to do this)
Hello: I'm loosing my mind trying to classify my outgoing messages with sieve-test (2.0.9, centos 6.4). It came to the point I think it's not even possible with a sieve script. I need to classify my outgoing messages in three folders: 1- To my department (@dept.example.com) 2- To my company (@example.com, @anyotherdept.example.com) (anyotherdept.example.com as in a way to say "any other domain that ends with 'example.com', but not 'dept.example.com'") 3- To the rest of the word (@any.other.domain) The problematic requirement is I need to make a copy in EVERY IMAP folder that applies. For instance: for an email such as ---- From: myuser at dept.example.com To: user at dept.example.com, user at example.com, user at other.domain ... ---- I need to make a copy to all folders: Dept (because of user at dept.example.com), Company (because of user at example.com) and Rest (because of user at other.domain). Rule for #1 is simple: ----- if address :matches :domain "To" "dept.example.com" { fileinto: "Dept"; } ----- Rule for #2, I don't know how to declare it: I don't know how to make a rule that matches "example.com" (or anyotherdept.example.com) and not "dept.example.com". if allof(address :matches :domain "To" "example.com", not address :matches :domain "To" "dept.example.com") { fileinto: "Company"; } ... doesn't work, because user at dept.example.com matches (address :matches :domain "To" "example.com"), but it doesn't matches (not address :matches :domain "To" "dept.example.com"). "user at example.com" matches both conditions, but sieve-test stops on the first email address with a "not matches" As for Rule #3: I don't know how to do it either, it should be the same as Rule #2, (with different parameters of course). A sieve script should be capable to do this, but it seems that I'm loosing something. Does any one knows how to do this? Kind regards Yanko PS: English is not my native language. Please forgive me any mistakes/misspellings/etc I made.
Robert Schetterer
2013-Nov-14 19:43 UTC
[Dovecot] Sieve script problem (don't know if is it possible to do this)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Am 14.11.2013 19:17, schrieb Yanko Hern?ndez ?lvarez:> Hello: > > I'm loosing my mind trying to classify my outgoing messages with > sieve-test (2.0.9, centos 6.4). It came to the point I think it's > not even possible with a sieve script. > > I need to classify my outgoing messages in three folders:stop here , filter outgoing mail is not possible yet with sieve, at my current info level, but it may come in future ( but thats a different story ) but your mail client may do copy in different imap folders at send time, or your mailserver may do some kind of sort/copy with i.e bcc feature etc equal stuff was asked before on the list i think , search archive however if i dont unterstand you in the right way, and you want to sort incomming mail feel free to ask again> > 1- To my department (@dept.example.com) 2- To my company > (@example.com, @anyotherdept.example.com) (anyotherdept.example.com > as in a way to say "any other domain that ends with 'example.com', > but not 'dept.example.com'") 3- To the rest of the word > (@any.other.domain) > > The problematic requirement is I need to make a copy in EVERY IMAP > folder that applies. For instance: for an email such as ---- From: > myuser at dept.example.com To: user at dept.example.com, > user at example.com, user at other.domain ... ---- I need to make a copy > to all folders: Dept (because of user at dept.example.com), Company > (because of user at example.com) and Rest (because of > user at other.domain). > > Rule for #1 is simple: ----- if address :matches :domain "To" > "dept.example.com" { fileinto: "Dept"; } ----- > > Rule for #2, I don't know how to declare it: I don't know how to > make a rule that matches "example.com" (or > anyotherdept.example.com) and not "dept.example.com". > > if allof(address :matches :domain "To" "example.com", not address > :matches :domain "To" "dept.example.com") { fileinto: "Company"; } > ... doesn't work, because user at dept.example.com matches (address > :matches :domain "To" "example.com"), but it doesn't matches (not > address :matches :domain "To" "dept.example.com"). > > "user at example.com" matches both conditions, but sieve-test stops > on the first email address with a "not matches" > > As for Rule #3: I don't know how to do it either, it should be the > same as Rule #2, (with different parameters of course). > > A sieve script should be capable to do this, but it seems that I'm > loosing something. Does any one knows how to do this? > > Kind regards Yanko > > PS: English is not my native language. Please forgive me any > mistakes/misspellings/etc I made. >Best Regards MfG Robert Schetterer - -- [*] sys4 AG http://sys4.de, +49 (89) 30 90 46 64 Franziskanerstra?e 15, 81669 M?nchen Sitz der Gesellschaft: M?nchen, Amtsgericht M?nchen: HRB 199263 Vorstand: Patrick Ben Koetter, Axel von der Ohe, Marc Schiffbauer Aufsichtsratsvorsitzender: Florian Kirstein -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBAgAGBQJShSf0AAoJEP8jBObu0LlEJtAH/127BkvFTC/00eK6j7xOnGtP NoIGbtYih/ySDMD0COklazVe+36+QWawmIkKLtUmDAYPo5TaSJw5GN40vTl3NYHl mEQpzjAlHW8kPyIvlPiZIKju6PGSzHtJXnOQovFmN2327HwvM2B+nEhccWIhDy0a NtnR3URu5iiFN1yZis2wpCBrriCmT4aFCo7DnTLnED5I4dvychbNehGYUhCi0z69 +IKSl4tplV//lVo4BsHzi/Hk+ewVSZsMgimXVOm6namS8m1l1vAGnsrWbOK4S5KN KTHpE9yrt/cBw+0Cr/ZDry3NEcQw1KxYNyq61oLFYWYPYSvCuBloll2AbSAp8ys=AhDy -----END PGP SIGNATURE-----
Muzaffer Tolga Ozses
2013-Nov-14 19:53 UTC
[Dovecot] Sieve script problem (don't know if is it possible to do this)
Maybe you can do it with postdrop? On 14 Nov 2013 20:18, "Yanko Hern?ndez ?lvarez" <yhdezalvarez at gmail.com> wrote:> > Hello: > > I'm loosing my mind trying to classify my outgoing messages with > sieve-test (2.0.9, centos 6.4). It came to the point I think it's not > even possible with a sieve script. > > I need to classify my outgoing messages in three folders: > > 1- To my department (@dept.example.com) > 2- To my company (@example.com, @anyotherdept.example.com) > (anyotherdept.example.com as in a way to say "any other domain that > ends with 'example.com', but not 'dept.example.com'") > 3- To the rest of the word (@any.other.domain) > > The problematic requirement is I need to make a copy in EVERY IMAP > folder that applies. For instance: for an email such as > ---- > From: myuser at dept.example.com > To: user at dept.example.com, user at example.com, user at other.domain > ... > ---- > I need to make a copy to all folders: Dept (because of > user at dept.example.com), Company (because of user at example.com) and Rest > (because of user at other.domain). > > Rule for #1 is simple: > ----- > if address :matches :domain "To" "dept.example.com" { fileinto: "Dept"; } > ----- > > Rule for #2, I don't know how to declare it: I don't know how to make > a rule that matches "example.com" (or anyotherdept.example.com) and > not "dept.example.com". > > if allof(address :matches :domain "To" "example.com", not address > :matches :domain "To" "dept.example.com") { fileinto: "Company"; } > ... doesn't work, because user at dept.example.com matches (address > :matches :domain "To" "example.com"), but it doesn't matches (not > address :matches :domain "To" "dept.example.com"). > > "user at example.com" matches both conditions, but sieve-test stops on > the first email address with a "not matches" > > As for Rule #3: I don't know how to do it either, it should be the > same as Rule #2, (with different parameters of course). > > A sieve script should be capable to do this, but it seems that I'm > loosing something. Does any one knows how to do this? > > Kind regards > Yanko > > PS: English is not my native language. Please forgive me any > mistakes/misspellings/etc I made.
Stephan Bosch
2013-Nov-14 20:30 UTC
[Dovecot] Sieve script problem (don't know if is it possible to do this)
On 11/14/2013 7:17 PM, Yanko Hern?ndez ?lvarez wrote:> Hello: > > I'm loosing my mind trying to classify my outgoing messages with > sieve-test (2.0.9, centos 6.4). It came to the point I think it's not > even possible with a sieve script.Outgoing? Sieve is currently only applicable to incoming e-mail. If you managed to do something like this, I'd be interested to find out how. :)> I need to classify my outgoing messages in three folders: > > 1- To my department (@dept.example.com) > 2- To my company (@example.com, @anyotherdept.example.com) > (anyotherdept.example.com as in a way to say "any other domain that > ends with 'example.com', but not 'dept.example.com'") > 3- To the rest of the word (@any.other.domain) > > The problematic requirement is I need to make a copy in EVERY IMAP > folder that applies. For instance: for an email such as > ---- > From: myuser at dept.example.com > To: user at dept.example.com, user at example.com, user at other.domain > ... > ---- > I need to make a copy to all folders: Dept (because of > user at dept.example.com), Company (because of user at example.com) and Rest > (because of user at other.domain). >This should solve the first two: require "fileinto"; require "relational"; if address :is :domain "To" "dept.example.com" { fileinto "Dept"; } if allof ( address :value "ne" :domain "To" "dept.example.com", anyof ( address :matches :domain "To" "*.example.com", address :is :domain "To" "example.com")) { fileinto "Company"; } Unfortunately, I cannot find a way to do #3. Perhaps some extremely convolved regular expression, but I wouldn't want to go there. Basically one needs to test that at least one of the addresses in the message does not match *.example.com, but I don't see how that could be achieved. Regards, Stephan.
Benny Pedersen
2013-Nov-14 22:08 UTC
[Dovecot] Sieve script problem (don't know if is it possible to do this)
Yanko Hern?ndez ?lvarez skrev den 2013-11-14 19:17:> I'm loosing my mind trying to classify my outgoing messages with > sieve-test (2.0.9, centos 6.4). It came to the point I think it's not > even possible with a sieve script.before you loose your hair aswell, have you consider trying roundcube on localhost ? and setup it to the problematic domain email server with imap and sieve support ? when it works you have a sieve rule that works :)
Steffen Kaiser
2013-Nov-15 07:34 UTC
[Dovecot] Sieve script problem (don't know if is it possible to do this)
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thu, 14 Nov 2013, Yanko Hern?ndez ?lvarez wrote:> I'm loosing my mind trying to classify my outgoing messages with > sieve-test (2.0.9, centos 6.4). It came to the point I think it's not > even possible with a sieve script. > > I need to classify my outgoing messages in three folders:As others told already, you can filter incoming messages only, but you can make outgoing into incoming messages with BCC. You will have to have an unique way to identify your BCC'ed messages, however. E.g.: a) Add a custom header, say "X-X-Yanko", in your MUA. If possible remove that header by your MTA if the message leaves your network b) use detail (subaddressing), if your MTA allows that: user+detail@ c) use a completely different account that spools into the mail storage of your normal account d) ...> 3- To the rest of the word (@any.other.domain)Would the normal "sent" folder be OK? There you would have 1+2+3 merged. Another idea is in the reply to Stephan's post. - -- Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEVAwUBUoXOb13r2wJMiz2NAQJLYgf/b9IZLunFOdgX2tLH/5WZI5msUlQx41TZ 0bsykwCYSZWeGxmB1fnsFmiFLiJJ7F2xqsX2N8YwOYMmKB3iQ/a8O8c+I+3hwmGD Jk1TGmUZ6mdtBk1nOXqDbWIUXEGvH2YRqTG+yyUaDg/z6gAr/xq7OIBlvm7887CJ ciEueGV7x/SCk25K2HNFpovg65ZYjERDjeXaY51mtL/yb7Vp1FQ71Xkr6MQt3yUT 9phZKZOOTylO312/sQVz0RP/ZLethnKeisKcBWZg4LUS12sdVEzy7PXCZgUNE1OP OsFjkleykQIzXR/lio8MiBVcTWkoL0tpAUQ5ryF217b/0oT2YC6iKQ==olis -----END PGP SIGNATURE-----
Yanko Hernández Álvarez
2013-Nov-15 14:08 UTC
[Dovecot] Fwd: Sieve script problem (don't know if is it possible to do this)
Ok, let simplify a little bit the problem: Forget about outgoing or incoming mail. Forget about IMAP or SMTP. You have a ton of emails in raw form (RFC-XXX, don?t remember the exact number right now) you want to classify? and you think: ?Sieve is a language made to do exactly that kind of task? If only I could use the same mechanism dovecot-lda uses! Oh, wait? ?sieve-test ?e? does exactly that!!! I could use it!!!?? but so far? no success. Now, a little more context. I want to leave a copy (a historical record) of every email (work related) I received/sent. The processing/classification doesn?t have to be in real time, it can be on ?down time/offline/later/scheduled?. Sent messages are hard, because of the several senders and the several copies on several folders. But I can work around it, with various tricks (bcc, different headers, etc.) and adjusting the processing sieve script. I can train myself ?The interest is mine after all!-, and that?s OK. But I can?t train other people to suit my needs. And received messages are JUST AS HARD. Because I want to classify them using the same rules. I also want to keep context, to record all things work related, not only what I said, but also what was said by others, using the same rules (which by the way, are many more than the restricted example I posted). Besides, I want the PC do all the work for me, not the other way around. I think ?Sieve must be capable of doing it! This is the kind of things sieve was designed for!? is a reasonable idea. But so far, no success? :-( Now, let me see all the replies in detail... (I really appreciate all the help I'm getting, thank you all very much) Yanko On 11/15/13, Stephan Bosch <stephan at rename-it.nl> wrote:> On 11/15/2013 8:41 AM, Steffen Kaiser wrote: >> Hi Stephan, about #3 how about the variable extension? I never used it so >> far, but it should work > > Congratulations! You fell into the same trap I did when I first saw this > problem. :) > > Consider this header: > > To: user at dept.example.com, user at example.com, user at other.domain > > >> > require "fileinto"; >> > require "relational"; >> >> require "variables"; >> >> set "done" "0"; >> >> > if address :is :domain "To" "dept.example.com" { >> > fileinto "Dept"; >> >> set "done" "1"; >> >> > } > > The variable "done" is set to "1", due to the first address. > >> > if allof ( >> > address :value "ne" :domain "To" "dept.example.com", >> > anyof ( >> > address :matches :domain "To" "*.example.com", >> > address :is :domain "To" "example.com")) { >> > fileinto "Company"; >> >> set "done" "1"; >> > } > > The variable "done" is set to "1", due to the second address. And now > that I think of it, it would also work on the combination of the first > and the third, making this rule still inadequate. > >> if string :is "${done}" "0" { >> fileinto "other"; >> } > > Since "done" is set to "1", the message is not filed into "other". But > that is wrong, due to the presence of the third address. > > See the core of the problem now? :) > > Regards, > > Stephan. > >