Alexis Lelion
2012-Mar-15 09:48 UTC
[Dovecot] sieve.before script is taking preceedence over user defined rules
Hello, In my current setup, I have a spam filter upstream that adds a specific header - X-Spam-Level on every incoming mail. Based on this level, the mail will be moved to the user spam folder using sieve by doing "fileinto :create 'spam';" Unfortunately, some legitimate email may end up in this spam folder, so I have kind of a whitelist that performs an explicit keep over specific trusted domains. So, my complete spam filtering rule is : if address :domain :contains "From" ["mycompany.tld", "trusted.tld" ]{ ??? keep; elseif header :contains "X-Spam-Level" ["0","1","2"] { ??? fileinto :create "__spam__"; } This rule is stored in "/var/lib/dovecot/sieve/before.sieve", which is my "sieve_before" file as defined in /etc/dovecot/conf.d/90-sieve.conf This works as expected except that it doesn't take into account users filtering for domains that were matched for the explicit keep. For example, I have the following rule : if address :domain "From" "trusted.tld" { ??? fileinto "trusted" } But mail coming from that domain are still delivered in my mailbox. Is there something I'm missing here? I guess yes, otherwise it would work as I want ^_^ Any help/comment is appreciated Thanks! Alexis
Stephan Bosch
2012-Mar-15 11:11 UTC
[Dovecot] sieve.before script is taking preceedence over user defined rules
Op 3/15/2012 10:48 AM, Alexis Lelion schreef:> Hello, > > In my current setup, I have a spam filter upstream that adds a > specific header - X-Spam-Level on every incoming mail. Based on this > level, the mail will be moved to the user spam folder using sieve by > doing "fileinto :create 'spam';" > Unfortunately, some legitimate email may end up in this spam folder, > so I have kind of a whitelist that performs an explicit keep over > specific trusted domains. So, my complete spam filtering rule is :require ["fileinto", "mailbox"]; if address :domain :contains "From" ["mycompany.tld", "trusted.tld" ] { keep; } elsif header :contains "X-Spam-Level" ["0","1","2"] { fileinto :create "__spam__"; } Fixed a few syntax issues there before I could test this.> This rule is stored in "/var/lib/dovecot/sieve/before.sieve", which is > my "sieve_before" file as defined in /etc/dovecot/conf.d/90-sieve.confWhat version are you using? The above statement hints that it is recent, probably Dovecot v2.1 with matching Pigeonhole.> This works as expected except that it doesn't take into account users > filtering for domains that were matched for the explicit keep. For > example, I have the following rule : > if address :domain "From" "trusted.tld" { > fileinto "trusted" > } > But mail coming from that domain are still delivered in my mailbox.At my end, this is correctly delivered in the "trusted" folder, provided that this folder exists. Are you sure that the user's personal script even executes correctly? For example, the above script omits a ';'. The script also fails when there is n no "trusted" folder. Check the log files for errors. The default action in the event of an error is to store the message in INBOX, which may well be what you're seeing here. Regards, Stephan.