[Dovecot Antispam] Can't seem to load plugin

james at lottspot.com james at lottspot.com
Tue Jul 21 03:53:10 UTC 2015


So after being totally dumbfounded by what the hell could possibly be
happening in the CRM114 backend that would just produce silent failure, 
I
decided to go for a wrapper script using the mailtrain backend. Here's 
what I
drummed up

plugin {
   antispam_trash_pattern_ignorecase  = Trash
   antispam_spam_pattern_ignorecase   = Spam
   antispam_unsure_pattern_ignorecase = Suspect
   antispam_backend = mailtrain
   antispam_mail_sendmail      = 
/usr/local/etc/dovecot/filter/mailreaver.sh
   antispam_mail_sendmail_args = %h
   antispam_mail_spam          = --spam
   antispam_mail_notspam       = --good
}

Where mailreaver.sh is:

#!/bin/sh
#DEBUG=1
TARGET='mailreaver.crm'
USRHOME=$1
ACTION=$2
SPAMDB="$USRHOME/spamdb"
LOGFILE="$USRHOME/logs/antispam"
DEBUGLOG='/dev/null'
test $DEBUG && DEBUGLOG="$LOGFILE"
STAMP=$(date +'[%Y %b %d %H:%M:%S]')
exec 1>>$DEBUGLOG
exec 2>>$LOGFILE
cd $SPAMDB
printf '%s In %s: Executing: %s\n' "$STAMP" "$PWD" "./$TARGET $ACTION"
>> $LOGFILE
exec ./$TARGET $ACTION

Using this method I figured out that the problem was I had neglected to 
set
mailtrainer.crm as executable. A very simple oversight, but one that was
insanely frustrating to figure out since it wasn't producing any log 
messages.
I think I'll continue to use this backend so that I can log each action, 
and
would personally recommend that anyone using CRM do something similar
rather than using the builtin CRM backend. Hopefully this is helpful to
someone, someday :)

On 2015-07-20 05:59, James Lott wrote:
> So I modified my configuration a couple times just to try and get any 
> results
> from the plugin. I commented out my backend configuration, and finally 
> got the
> plugin to log something.
> 
> root at zerolag:/usr/local/etc/dovecot # grep antispam /var/log/maillog
> Jul 20 05:27:50 zerolag dovecot: imap(james.lott): Error: antispam 
> plugin
> backend is not selected for this user
> 
> At this point, I'll take it.
> 
> After that I modified my antispam configuration and changed up my 
> directory
> hierarchy a bit
> 
> root at zerolag:/home/james.lott/mail # ls -1
> .Archive
> .Drafts
> .Notes
> .Sent
> .Spam
> .Suspect
> .Trash
> cur
> dovecot-uidlist
> dovecot-uidvalidity
> dovecot-uidvalidity.55a4236f
> dovecot.index
> dovecot.index.cache
> dovecot.index.log
> dovecot.index.log.2
> dovecot.index.thread
> dovecot.mailbox.log
> new
> subscriptions
> tmp
> 
> plugin {
>   antispam_debug_target = syslog
>   antispam_verbose_debug = 1
>   antispam_trash_pattern_ignorecase  = Trash
>   antispam_spam_pattern_ignorecase   = Spam
>   antispam_unsure_pattern_ignorecase = Suspect
>   antispam_backend  = spool2dir
>   antispam_spool2dir_spam = /home/%u/unprocessed/spam-%%lu-%%lu
>   antispam_spool2dir_notspam = /home/%u/unprocessed/ham-%%lu-%%lu
> }
> 
> After reloading with this configuration and moving a piece of spam into 
> the
> spam folder...
> 
> root at zerolag:/home/james.lott/mail # ls -lah ../unprocessed/
> total 12
> drwxr-xr-x  2 james.lott  mail   512B Jul 20 05:50 .
> drwxr-xr-x  9 james.lott  mail   1.0K Jul 20 05:44 ..
> -rw-------  1 james.lott  mail   2.1K Jul 20 05:50 spam-1437396653-1
> 
> Success! Unfortunately, though, I also noticed that action was not 
> logged. So
> it seems that logging in this plugin is just completely bunk.
> 
> Still no dice after switching to the crm backend though, so something 
> about
> the way I've set that up must not be working. This is mega progress 
> though.
> Thanks for the tips everyone!
> 
> On Monday, July 20, 2015 08:39:54 Christian Kivalo wrote:
>> On 2015-07-20 08:20, Christian Kivalo wrote:
>> >> That seems to be about all I get though. Still nothing to indicate
>> >> errors, and
>> >> nothing to indicate that anything is being done when I move messages
>> >> into
>> >> spam. I suppose that probably means I've configured the folder paths
>> >> incorrectly. I'll have to keep beating my head against it and see
>> >> where it
>> >> takes me.
>> >
>> > it would help to see your dovecot -n output here.
>> 
>> Ok, found it in the first mail...
>> 
>> Do these folders exist in the filesystem? The case matches?
>> I use antispam_{spam,trash}_pattern_ignorecase and don't care about 
>> the
>> case of the folders...
>> 
>> plugin {
>>    antispam_backend = crm114
>>    antispam_crm_args = --fileprefix=/home/%u/spamdb/
>>    antispam_crm_binary = /usr/local/etc/dovecot/filter/mailreaver.crm
>>    antispam_debug_target = syslog
>>    antispam_signature = X-CRM114-CacheID
>>    antispam_spam = Spam
>>    antispam_trash = Trash
>>    antispam_unsure = INBOX/Suspect
>> 
>> i don't know crm114 but this looks ok to me.
>> 
>> you could try
>> 
>> antispam_verbose_debug = 1
>> 
>> to get more verbose logging from the antispam plugin
>> 
>> regards
>> - christian


More information about the dovecot mailing list