This documentation is for Dovecot v2.x, see wiki1 for v1.x documentation.
Differences between revisions 15 and 17 (spanning 2 versions)
Revision 15 as of 2014-11-01 13:33:08
Size: 4471
Editor: juz78-1-78-218-80-186
Revision 17 as of 2014-11-01 14:19:24
Size: 4481
Editor: juz78-1-78-218-80-186
Deletions are marked like this. Additions are marked like this.
Line 58: Line 58:
Line 59: Line 60:
Line 60: Line 62:
echo /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt
echo "$$-start ($*)" >> /tmp/sa-learn-pipe.log
Line 63: Line 63:
#echo $* > /tmp/sendmail-parms.txt
cat<&0 >> /tmp/sendmail-msg-$$.txt
echo /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt echo "$$-start ($*)" >> /tmp/sa-learn-pipe.log
Line 66: Line 65:
/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt #echo $* > /tmp/sendmail-parms.txt cat<&0 >> /tmp/sendmail-msg-$$.txt

/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt &
Line 73: Line 74:
Line 74: Line 76:

Antispam plugin


The antispam plugin allows you to retrain the spam filter by simply moving emails in and out of the Spam folder. This is the fork of the analogous plugin for Dovecot versions prior to v2.0. The original project can be found HERE.

Getting the sources


None so far.


Execute the following commands in order to get the source from the Mercurial repository:

# hg clone
# cd dovecot-antispam-plugin

There is a web interface available HERE.


If you downloaded the sources using Mercurial, you will need to execute ./ first to build the automake structure in your source tree. This process requires autotools and libtool to be installed.

If you installed Dovecot from sources, antispam-plugin's configure script should be able to find the files it needs automatically, just make sure the --prefix=<path> is specified correctly:

# ./configure --prefix=/usr
# make
# make install

If you get a DC_DOVECOT: not found" error message when running configure, make sure dovecot.m4 is in your aclocal folder. If you installed dovecot in an unusual location, you can also specify the path to the directory containing dovecot.m4 when you run like so:

# ACLOCAL='aclocal -I /path/to/directory' ./

In this case, you will probably also want to append --with-dovecot=/path/to/dovecot/include/directory when you run ./configure.

Configuration and Use

Please refer to the manual page dovecot-antispam(7) installed during the make install or view the textual version online HERE.

Sieve filter

If you would like to have Dovecot move the spam tagged emails simply place the following into '.dovecot.sieve', and place the file into the users root mail folder (the folder with 'Maildir' in it).

require ["fileinto","imapflags"];
if header :contains "subject" ["[SPAM]"] {
        setflag "\\seen";
        fileinto "SPAM";
} else {
        # The rest goes into INBOX
        # default is "implicit keep", we do it explicitly here

Backend - mailtrain realtime sa-learn

If you intend to use the mailtrain backend linked to sa-learn you will need to pipe the output to a file though a wrapper script as sa-learn does not support piped input. The script below needs to be put in /usr/bin/ and chmod'ed to allow dovecot to execute it. Note that the script below has a couple extra lines used to create a log of when it has been run.



echo /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt echo "$$-start ($*)" >> /tmp/sa-learn-pipe.log

#echo $* > /tmp/sendmail-parms.txt cat<&0 >> /tmp/sendmail-msg-$$.txt

/usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt &

rm -f /tmp/sendmail-msg-$$.txt

echo "$$-end" >> /tmp/sa-learn-pipe.log

exit 0


    # mailtrain plugin
    # This plug can be used to train via an arbitrary program that
    # receives the message on standard input. Since sendmail can be
    # such a program, it can be used to send the message to another
    # email address for training there.
    # For example:
    #        (defaults to /usr/sbin/sendmail)
    #antispam_mail_sendmail_args  = --for;%u
    antispam_mail_spam  = --spam
    antispam_mail_notspam  = --ham
    #antispam_mail_sendmail = /usr/sbin/sendmail
    antispam_mail_sendmail = /usr/bin/
    #antispam_mail_sendmail_args = -f; # % expansion done by dovecot


Please report the bugs, feature requests, or anything else regarding this plugin to its author and maintainer: Eugene Paskevich.


Note: Do not use chrooting because otherwise it might be impossible to find the binary the antispam plugin tries to execute. Or make sure the executed binary and the spam db is available in all home directories.

None: Plugins/Antispam (last edited 2017-02-10 07:49:27 by officewifi)