colinh at nxtgn.com
2018-Feb-24 21:02 UTC
Dovecot With DSpam AntiSpam Plugin Replacement With Sieve
Hello I have recently had to rebuild my email server, it is a small server for my various email accounts and I also host the email for a clients business. Switched to Dovecot from Courier many years ago, and it has been a very reliable solution With the new rebuild I have updated it to Dovecot 2.2.33.2 with PigeonHole 4.21, it runs DSpam 3.10.2 to scan and tag all incoming mails as Spam or not then a Sieve rule to put the Spam emails into the Spam folder, I was also using the DSpam Antispam plugin to enable moving messages from one folder to another to teach failures to DSpam, this works well for my and my client. Doing the rebuild I saw that the AntiSpam plugin had been deprecated and the preferred solution now was to use Sieve Filters, so I implemented that and had struggled with it for a few hours until I finally got it working. It may be something about my setup but I am not sure it is, but the suggested way of doing it here https://wiki.dovecot.org/HowTo/AntispamWithSieve did not work for me and I don't think it was ever going to. Here are the shell scripts and sieve filters that I came up with that work for me, your mileage may vary. I use DSpam as a standalone binary not as a daemon so you may need to add the --client option on the dspam command line in the shell scripts if you run DSpam in daemon mode. === report-spam.sieve == require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; if environment :matches "imap.user" "*" { set "userid" "${1}"; if header :matches "X-DSPAM-Signature" "*" { set "signature" "${1}"; } } pipe :copy "learn-spam.sh" [ "${userid}", "${signature}" ]; === report-ham.sieve == require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"]; if environment :matches "imap.mailbox" "*" { set "mailbox" "${1}"; } if string "${mailbox}" "Trash" { stop; } if environment :matches "imap.user" "*" { set "userid" "${1}"; if header :matches "X-DSPAM-Signature" "*" { set "signature" "${1}"; } } pipe :copy "learn-ham.sh" [ "${userid}", "${signature}" ]; === learn-spam.sh == #!/bin/sh exec /usr/local/bin/dspam --user ${1} --signature=${2} --class=spam --source=error === learn-ham.sh == #!/bin/sh exec /usr/local/bin/dspam --user ${1} --signature=${2} --class=innocent --source=error I hope this saves someone some time or gives someone some tips -- Regards Colin
Trever L. Adams
2018-Feb-25 05:25 UTC
Dovecot With DSpam AntiSpam Plugin Replacement With Sieve
Thank you for this. I have a DSPAM setup that did work with the suggested scrips, but I used the old dovecot antispam plugin and enjoyed the signature method. I am going to try this out next week to see if it works for me. If it does, I will love this. Thanks again. Trever On 02/24/2018 02:02 PM, colinh at nxtgn.com wrote:> Hello > > I have recently had to rebuild my email server, it is a small server > for my various email accounts and I also host the email for a clients > business. > > Switched to Dovecot from Courier many years ago, and it has been a > very reliable solution With the new rebuild I have updated it to > Dovecot 2.2.33.2 with PigeonHole 4.21, it runs DSpam 3.10.2 to scan > and tag all incoming mails as Spam or not then a Sieve rule to put the > Spam emails into the Spam folder, I was also using the DSpam Antispam > plugin to enable moving messages from one folder to another to teach > failures to DSpam, this works well for my and my client. > > Doing the rebuild I saw that the AntiSpam plugin had been deprecated > and the preferred solution now was to use Sieve Filters, so I > implemented that and had struggled with it for a few hours until I > finally got it working. > > It may be something about my setup but I am not sure it is, but the > suggested way of doing it here > https://wiki.dovecot.org/HowTo/AntispamWithSieve did not work for me > and I don't think? it was ever going to. > > Here are the shell scripts and sieve filters that I came up with that > work for me, your mileage may vary. > > I use DSpam as a standalone binary not as a daemon so you may need to > add the --client option on the dspam command line in the shell scripts > if you run DSpam in daemon mode. > > === report-spam.sieve ==> > require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", > "variables"]; > > > if environment :matches "imap.user" "*" { > ? set "userid" "${1}"; > ? if header :matches "X-DSPAM-Signature" "*" > ? { > ?????? set "signature" "${1}"; > ? } > } > > pipe :copy "learn-spam.sh" [ "${userid}", "${signature}" ]; > > === report-ham.sieve ==> > require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", > "variables"]; > > if environment :matches "imap.mailbox" "*" { > ? set "mailbox" "${1}"; > } > > if string "${mailbox}" "Trash" { > ? stop; > } > > if environment :matches "imap.user" "*" { > ? set "userid" "${1}"; > ? if header :matches "X-DSPAM-Signature" "*" > ? { > ?????? set "signature" "${1}"; > ? } > } > > pipe :copy "learn-ham.sh" [ "${userid}", "${signature}" ]; > > === learn-spam.sh ==> > #!/bin/sh > exec /usr/local/bin/dspam --user ${1} --signature=${2} --class=spam > --source=error > > === learn-ham.sh ==> > #!/bin/sh > exec /usr/local/bin/dspam --user ${1} --signature=${2} > --class=innocent --source=error > > > I hope this saves someone some time or gives someone some tips >-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 886 bytes Desc: OpenPGP digital signature URL: <https://dovecot.org/pipermail/dovecot/attachments/20180224/6b9b85c2/attachment.sig>