Dovecot2 Antispam MAILTRAIN backend with SpamAssassin

Mohammad S. Babaei info at babaei.net
Tue Jul 15 13:00:13 UTC 2014


 

Hi there, 

I've already asked this question on FreeBSD forums without getting any
response. So, I thought it's a good idea to ask it again here. 

I've setup Dovecote2 (2.2.13) + Postfix + SpamAssassin on my FreeBSD 10
VPS and it works flawlessly. Though, I couldn't setup the Dovecot
Antispam plugin to train SpamAssassin when I move mails to the Junk
folder.

I installed the plugin from FreeBSD ports and followed the official
documentation [1] and the man page [2] without any success. 

This is my configuration: 

######## 

# 2.2.13: /usr/local/etc/dovecot/dovecot.conf
# OS: FreeBSD 10.0-RELEASE-p6 i386 ufs
auth_mechanisms = plain login digest-md5
disable_plaintext_auth = no
first_valid_gid = 6
first_valid_uid = 26
last_valid_gid = 6
last_valid_uid = 26
lmtp_save_to_detail_mailbox = yes
mail_gid = mail
mail_location = mdbox:/mail/%d/%u
mail_privileged_group = mail
mail_uid = mailnull
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope
encoded-character vacation subaddress comparator-i;ascii-numeric
relational regex imap4flags copy include variables body enotify
environment mailbox date ihave
namespace inbox {
 inbox = yes
 location =
 mailbox Archive {
 auto = no
 special_use = Archive
 }
 mailbox Drafts {
 auto = subscribe
 special_use = Drafts
 }
 mailbox Flagged {
 auto = no
 special_use = Flagged
 }
 mailbox Junk {
 auto = subscribe
 special_use = Junk
 }
 mailbox Sent {
 auto = subscribe
 special_use = Sent
 }
 mailbox Trash {
 auto = subscribe
 special_use = Trash
 }
 mailbox virtual/All {
 auto = no
 special_use = All
 }
 prefix =
 separator = /
}
passdb {
 args = /mail/%d/dovecot_passwd
 driver = passwd-file
}
plugin {
 antispam_backend = MAILTRAIN
 antispam_mail_notspam = --ham
 antispam_mail_sendmail = /mail/sa-learn-pipe.sh
 antispam_mail_spam = --spam
 antispam_spam = Junk
 antispam_trash = Trash
 quota_rule = *:storage=8GB
 sieve = /mail/%d/%u/dovecot.sieve
 sieve_dir = /mail/%d/%u
 sieve_global_dir = /mail/sieve
 sieve_global_path = /mail/sieve/globalfilter.sieve
}
protocols = imap pop3 lmtp sieve
service auth {
 unix_listener auth-client {
 group = mail
 mode = 0660
 user = postfix
 }
 unix_listener auth-master {
 group = mail
 mode = 0600
 user = mailnull
 }
 user = root
}
service imap-login {
 inet_listener imap {
 address = *
 port = 143
 }
 inet_listener imaps {
 address = *
 port = 993
 }
 process_limit = 32
 process_min_avail = 1
}
service lmtp {
 unix_listener /var/spool/postfix/private/dovecot-lmtp {
 group = postfix
 mode = 0660
 user = postfix
 }
}
service managesieve-login {
 inet_listener sieve {
 port = 4190
 }
 process_min_avail = 0
 service_count = 1
 vsz_limit = 64 M
}
service managesieve {
 process_limit = 1024
}
service pop3-login {
 inet_listener pop3 {
 address = *
 port = 110
 }
 inet_listener pop3s {
 address = *
 port = 995
 }
 process_limit = 32
 process_min_avail = 1
}
ssl_cert = </etc/ssl/dovecot/cert.pem
ssl_key = </etc/ssl/dovecot/key.pem
userdb {
 args = /mail/%d/dovecot_passwd
 driver = passwd-file
}
verbose_proctitle = yes
protocol lmtp {
 mail_plugins = " sieve"
 postmaster_address = postmaster at SomeDomain.com
 quota_full_tempfail = yes
}
protocol sieve {
 mail_max_userip_connections = 10
 managesieve_implementation_string = Dovecot Pigeonhole
 managesieve_logout_format = bytes=%i/%o
 managesieve_max_line_length = 65536
}
protocol imap {
 imap_client_workarounds = delay-newmail tb-extra-mailbox-sep
 mail_plugins = " quota imap_quota antispam"
}
protocol pop3 {
 mail_plugins = " quota"
 pop3_client_workarounds = outlook-no-nuls oe-ns-eoh
}
protocol lda {
 mail_plugins = " quota sieve"
 postmaster_address = postmaster at SomeDomain.com
 sendmail_path = /usr/local/sbin/sendmail
} 

######## 

And, this is the script /mail/sa-learn-pipe.sh: 

######## 

echo /usr/local/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/local/bin/sa-learn $* /tmp/sendmail-msg-$$.txt

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

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

exit 0 

######## 

I made it excecutable by all users using chmod a+x
/mail/sa-learn-pipe.sh

The problem is, there is no log in /var/log/maillog regarding the
Antispam plugin, and the script won't get called when I move any message
in/out to/from Junk folder.

I'll appreciate any help. 

-- 
"When I give, I give myself." - Walt Whitman
 

Links:
------
[1] http://wiki2.dovecot.org/Plugins/Antispam
[2]
http://hg.dovecot.org/dovecot-antispam-plugin/raw-file/tip/doc/dovecot-antispam.7.txt


More information about the dovecot mailing list