[Dovecot] Trouble implementing Antispam plug-in for Dovecot

Bill Shirley Bill at knoxvillechristian.org
Thu Sep 20 11:32:54 EEST 2012


On 9/19/2012 5:41 PM, Ben Johnson wrote:
>
> On 9/11/2012 10:40 AM, Ben Johnson wrote:
>> You nailed it, Ben. Thanks!
>>
>> I downloaded/installed the dovecot-dev package from the same maintainer
>> and was able to build Antispam without issue.
>>
>> The hang-up now seems to be with my configuration.
>>
>> I'm seeing the following error in my email client whenever I attempt to
>> move an email message from, say, Inbox to Junk folder:
>>
>> [SERVERBUG] BUG Unknown internal error.
>>
>> Nothing at all appears in syslog when this happens.
>>
>> I followed the instructions at http://wiki2.dovecot.org/Plugins/Antispam
>> , to the letter, I believe.
>>
>> The relevant portions of my configuration are as follows:
>>
>> ---------------------
>> protocol imap {
>>    mail_plugins = quota imap_quota antispam
>> }
>>
>> plugin {
>>    quota = dict:user::file:/var/vmail/%d/%n/.quotausage
>>    sieve = /var/vmail/%d/%n/.sieve
>>
>>    antispam_backend = MAILTRAIN
>>    antispam_mail_sendmail = /usr/bin/sa-learn-pipe.sh
>>    antispam_mail_spam = --spam
>>    antispam_mail_notspam = --ham
>>    antispam_spam_pattern_ignorecase = spam;junk
>> }
>> ---------------------
>>
>> The permissions and execute bit are set in accordance with other
>> executables in the same directory:
>>
>> # ls -lah /usr/bin/ | grep -i "sa-learn-pipe.sh"
>> -rwxr-xr-x  1 root root     297 Sep  5 11:17 sa-learn-pipe.sh
>>
>> I would provide more log content, but the debug options seem to be gone
>> in the forked, >= 2.0 version of this plug-in.
>>
>> Any ideas are very much appreciated.
>>
>> Thanks,
>>
>> -Ben
> Given that nobody shared any insight here, I decided to stand-up a
> completely new VM with Ubuntu 12.04 LTS and see if the same error occurs.
>
> While the error is different this time around, I am still unable to get
> any variant of the dovecot-antispam plug-in working.
>
> When I attempt to use the current packages from Ubuntu 12.04.1 LTS, and
> I use the above configuration, my syslog fills-up with the following:
>
> dovecot: imap-login: Login: user=<user at example.com>, method=PLAIN,
> rip=10.0.1.57, lip=10.0.1.8, mpid=2879, TLS
> dovecot: master: Error: service(imap): child 2879 returned error 3
>
> Surprisingly, I can find only two other mentions of "error 3" anywhere
> on the Internet. Those mentions were from another user to this mailing list:
>
> http://www.dovecot.org/list/dovecot/2012-August/067787.html
> http://www.dovecot.org/list/dovecot/2012-August/067814.html
>
> The lack of "error 3" ubiquity leads me to believe that I must be doing
> something stupid.
>
> There's no question that this behavior is related to the
> antispam-plugin, because when I commented-out the relevant lines in
> Dovecot's configuration file, the error does not occur.
>
> I have followed the instructions at
> http://wiki2.dovecot.org/Plugins/Antispam to the letter, and this is the
> result.
>
> The only instance in which I diverged from the Wiki article is that I
> used the Ubuntu-provided dovecot-antispam package (instead of compiling
> the plug-in from source).
>
> I am trying to use the "mailtrain" back-end, per the above-cited Wiki
> article, to call SpamAssassin's "sa-learn" utility for real-time learning.
>
> I am not using the SpamAssassin daemon (spamd).
>
> I'm about to throw in the towel on this plug-in, so any help would be
> greatly appreciated.
>
> Thank you,
>
> -Ben

I've never used this plugin but let offer up my home brewed script that 
I call from crontab:
# Process and delete .Spam and .Ham Maildirs
11 */4 * * *            /usr/local/sbin/maildir.sa-learn

and /usr/local/sbin/maildir.sa-learn:
#!/bin/bash

MAILDIR=Maildir

LS=/bin/ls
RM=/bin/rm
SU=/bin/su
FIND=/bin/find
SALEARN=/usr/bin/sa-learn

for i in `$LS /home`; do
         prefs="/home/$i/.spamassassin/user_prefs"

#       [ ! ."$i" == ".bill" ] && continue
echo $i
         spamdir="/home/$i/$MAILDIR/.SystemFolders.Spam"
         [ ! -d "$spamdir" ] && continue

         $SU -c "$SALEARN --prefspath=$prefs --spam $spamdir/new" $i
         $FIND "$spamdir/new" -type f -delete

         $SU -c "$SALEARN --prefspath=$prefs --spam $spamdir/cur" $i
         $FIND "$spamdir/cur" -type f -delete


         hamdir="/home/$i/$MAILDIR/.SystemFolders.Ham"
         [ ! -d "$hamdir" ] && continue

         $SU -c "$SALEARN --prefspath=$prefs --ham $hamdir/new" $i
         $FIND "$hamdir/new" -type f -delete

         $SU -c "$SALEARN --prefspath=$prefs --ham $hamdir/cur" $i
         $FIND "$hamdir/cur" -type f -delete
done

With my setup each user has their own spamassassin user_prefs and bayes 
tokens.

Bill




More information about the dovecot mailing list