Sieve Advice Needed, Please

Tamsy dovecot-list at mohtex.net
Fri Oct 24 02:47:10 UTC 2014


Casey Bralla wrote on 24.10.2014 09:26:
> Anybody here familiar with the Sieve language?
>
> I'm rebuilding my mail server, and I am working with the sieve language to
> automatically filter spam into a separate account.  However, I've hit a
> snag that I can't get around.
>
> BTW, I'm using a clean install of dovecot, postfix, spamassassin on Debian 7.5.
>
>
> I want to do server-side spam filtering, so I've got spamasassin
> identifying spam, and then have sieve sorting the mail to a special spam
> folder.   I can easily send spam to special folder in the inbox for each
> mail user, but I wanted to have a single mail account for spam.   I can use
> the "redirect" sieve command to send anything with the X-spam-flag set, but
> this triggers an error and bounces the offending mail.   The bounce message
> is:
>
>
> From: MAILER-DAEMON at NerdWorld.org (Mail Delivery System)
> To: casey at vmailservertest.nerdworld.org
> Subject: Undelivered Mail Returned to Sender
> Date: Sun, 19 Oct 2014 16:41:49 -0400 (EDT)
>
> This is the mail system at host VMailServerTest.NerdWorld.org.
>
> I'm sorry to have to inform you that your message could not
> be delivered to one or more recipients. It's attached below.
>
> For further assistance, please send mail to postmaster.
>
> If you do so, please include this problem report. You can
> delete your own text from the attached returned message.
>
>                     The mail system
>
> <spam at vmailservertest.nerdworld.org>: mail forwarding loop for
>      spam at vmailservertest.nerdworld.org
>
> From: casey at vmailservertest.nerdworld.org
> Date: Sun, 19 Oct 2014 16:41:20 -0400 (EDT)
>
> viagra!!!!
> www.viagra.com
>
>
>
>
> I think this is a recursion problem, since the redirected mail has to go
> through the spamassassin check and sieve again.   I tried to get clever and
> prevent the recursion, but I'm not clever enough.  Here is my sieve rule
> file.
>
> #
> #
> # A rule to move spam to the spam user
> #  based on spamassassin setting the spam flag
> #
> #
> # require ["redirect"]; (Not needed, since it is part of the basis sieve
> spec)
> #
> # rule:[SPAM]
> if header :contains "X-Spam-Flag" ["YES"]
>          {
>          if address :is "to" "Spam at VMailServerTest.NerdWorld.org"
>                  {
>                  keep;
>                  }
>          else
>                  {
>                  redirect "spam at VMailServerTest.NerdWorld.org";
>                  }
>          }
> #
> #
> #
>
> Anybody able to give me any advice?  TIA
>
>


We are using the below to file spam messages (tagged by Spamassassin) to 
a global Spam-mailbox for all users except for some system users. Still 
a copy of Spam gets delivered to the user's spam folder in case of false 
positives etc. We use this as a sieve before rule to all other rules and 
it works as expected.


require ["copy", "fileinto"];
if not anyof (address :is ["To", "Cc", "Bcc"] 
["Spam at VMailServerTest.NerdWorld.org"],
               address :is ["To", "Cc", "Bcc"] 
["postmaster at VMailServerTest.NerdWorld.org"],
               address :is ["To", "Cc", "Bcc"] 
["sysadmin at VMailServerTest.NerdWorld.org"],
               address :is ["To", "Cc", "Bcc"] 
["abuse at VMailServerTest.NerdWorld.org"],
               address :is ["To", "Cc", "Bcc"] 
["webmaster at VMailServerTest.NerdWorld.org"]){
if anyof (header :contains "X-Spam-Flag" "YES")
{
         redirect :copy "spam at VMailServerTest.NerdWorld.org";
         fileinto "Spam";
         stop;
         }
}



More information about the dovecot mailing list