Sieve rule for whitelisting domains after spam processing

hi at zakaria.website hi at zakaria.website
Wed Aug 10 08:12:42 UTC 2022


On 2022-08-10 06:09, Nicolae Iuoras wrote:
> Hello,
> 
> My mail server has a global Sieve rule defined in sieve_before to file
> messages classified as spam by spamassassin into the Spam folder:
> 
> require ["regex", "fileinto", "imap4flags"];
> 
> if allof (header :regex "X-Spam-Status" "^Yes") {
> 
>   fileinto "Spam";
> 
> }
> 
> This works great, except I'd like the ability to whitelist certain
> senders or domains whose emails end up in Spam, usually due to a
> misconfigured SPF DNS TXT record or something like that.  I use
> Roundcube as my Webmail client, so the easiest way to whitelist would
> be to create a rule for each domain directly in Roundcube using its
> built-in Sieve integration to move legitimate messages out of the Spam
> folder.  I already have several rules set up to flag and sort non-spam
> messages, and they're working fine.  I therefore tried adding a simple
> rule to move Spam into the Inbox:
> 
> # rule:[Not Spam]
> 
> if allof (header :contains "from" "user at good-domain.com")
> 
> {
> 
>         fileinto "INBOX";
> 
> }
> 
> However, the above rule does not work as I expected.  When I receive
> an email from good-domain.com that's classified as Spam by
> spamassassin, the global rule sends it to the Spam folder and it is
> not re-filed into the Inbox.  The second rule doesn't seem to do
> anything.  I'm probably doing something simple wrong, but I can't
> figure out what (I'm a Sieve newb).  Any suggestions please?
> 
> Thanks,
> 
> Nick

Hi Nick,

Can you post your full global sieve and RC sieve script?

It could be due to the order of if statements or the structure having to 
be in if and elseif instead of if else and use anyof instead of allof 
and if email is by default is going to INBOX, then just call command 
keep; in either at the top of if statement if the order of specific 
domain exclusion matters.

Otherwise in each if condition try to use stop; command.

Zakaria.



More information about the dovecot mailing list