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 -- Casey Bralla Chief Nerd in Residence The NerdWorld Organisation www.NerdWorld.org
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; } }
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Thu, 23 Oct 2014, Casey Bralla wrote:> 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.the easiest way would be to prevent Sieve filtering for "spam" at all. Or use another filter without this check.> # 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"; > } > }Did you've verified that "redirect" really alters the "to" header? Otherwise you need to use the envelope information. See http://wiki2.dovecot.org/Pigeonhole/Sieve - -- Steffen Kaiser -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQEVAwUBVEn3vnz1H7kL/d9rAQLpWggAtL976eZWk7xyI4WcqMMv6Zzuy4ylFf0z 2wbMt+YzuZ3oRWDw/K6Fqx4CqaWxte0MqdqzDpbJb2wrQSDXHRvs16oUOss0WN7o cL/o4mdI4sn9W1/I1+QZb5kb+CqAT8HgvWdek4kQYoG01QN8NtvtEEliRttMMT/D KAecKG+RvHdYfTOxyEAjKGcCZBspd928qCKZiqM4nyGtNM7tavLb9xaQd1ueRE/b UD54MY896+AemRUITMQDqbyDVHWIawcpCcoLMq2+uTGtatBhdUuNERcbXQrzj3cB kbXuJSMnODoOKYK0e/3ZMHPZYo5v/KQftasi0BACUHI8mTe0HUpMIw==KtCK -----END PGP SIGNATURE-----