Roundcube Community Forum

 

sieverules: spam filter with regex and variables?

Started by nbluemer, April 28, 2014, 05:05:44 AM

Previous topic - Next topic

nbluemer

Hello,
I have been using dovecot+sieve for some time, using an included spam filter. Now I managed to set up the roundcube plugin.

My question is: how can I integrate the following spam filter rule attached below (which used to be included in my former sieve setup)? The problem is that I don't know how to set variables in sieverules. I also could not get predefined rules to work.

Any help is appreciated.

-----------------------------------------------------------------------------------------------------------

# cat /var/vmail/xxx/yyy/Maildir/.dovecot.sieve
require ["fileinto", "include"];
....
include :global "spam";

-----------------------------------------------------------------------------------------------------------
# cat /etc/dovecot/sieve/spam.sieve

require ["variables", "relational","comparator-i;ascii-numeric", "regex","imap4flags","fileinto"];

# Extract integer from X-Spam-Score
set "iSpamLevel" "0";
if header :regex "X-Spam-Score" "([0-9]+)(\.[0-9]+)?" {
        set "iSpamLevel" "${1}";
}
if header :contains "X-Spam-Score" "-" {
   set "iSpamLevel" "0";
}
if header :contains "Subject" "BANNED" {
        set "iSpamLevel" "6";
}

# rule:[SpamLikely]
if allof (string :value "ge" :comparator "i;ascii-numeric" "${iSpamLevel}" "3",
        string :value "lt" :comparator "i;ascii-numeric" "${iSpamLevel}" "6")
{
        fileinto "Spamverdacht";
   stop;
}
# rule:[Spam]
elsif string :value "ge" :comparator "i;ascii-numeric" "${iSpamLevel}" "6"
{
   setflag "\\Seen";
        fileinto "Spam";
   stop;
}

JohnDoh

The sieverules plugin does not support the variables extension. I have thought about adding it in the past but I think its too advanced for most people and any one who did want it would probably rather use the advanced editor anyway (rather than being restricted by an end user friendly UI).

I think the managesieve plugin distributed with Roudcube supports the variables extension.
Roundcube Plugins: Contextmenu, SpamAssassin Prefs, and more...

alec

You don't need variables extension. This script can be rewritten to do the same without variables.