[Mimedefang] Cannot get spamassassin to use bayes
John Nemeth
jnemeth at victoria.tc.ca
Thu Nov 9 15:59:48 EST 2006
Date: Tue, 17 Oct 2006 15:37:40 +0200
From: Andrea Venturoli <ml at netfence.it>
Reply-To: mimedefang at lists.roaringpenguin.com
As per subject, I'm running the most recent stable versions of
sendmail+mimedefang+spamassassin on FreeBSD 5.4. Due to the latest
overwhelming increase in spam getting in I tryed enabling bayesian
filters: I trained spamassassin and manually checked that it works quite
effectively; however I cannot get it to apply bayes when called from
mimedefang.
I've put:
use_bayes 1
bayes_path /usr/local/etc/mail/spamassassin
in /usr/local/etc/mimedefang/sa-mimedefang.cf.
This will cause you to have one Bayesian database for all users.
Bayesian testing works best when done for each user individually. In
order to do this, you may want to store the bayes stuff in an SQL
database. However, I have to warn you that this can seriously bloat
MySQL databases. Mine are currently running at just under 4 GB and
99% of that is attributable to using it to store SpamAssassin bayes
stuff.
Having gotten the warning out of the way... You will need to be
using stream_by_recipient() to be able to process each user
individually. Also you will need
$SASpamTester->signal_user_changed({ username => $user });
prior to the call to spam_assassin_check(); In order to get the
$SASpamTester variable iniitialised, you will need this code in your
filter (it used to be in the sample filter, but has since been
removed):
# The next lines force SpamAssassin modules to be loaded and rules
# to be compiled immediately. This may improve performance on busy
# mail servers. Comment the lines out if you don't like them.
if ($Features{"SpamAssassin"}) {
spam_assassin_init()->compile_now(1) if defined(spam_assassin_init());
}
You will also need to add some lines to your
/etc/mail/sa-mimedefang.cf file:
bayes_store_module Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn DBI:mysql:spamassassin:localhost
bayes_sql_username spamuser
bayes_sql_password XXX
bayes_auto_learn_threshold_nonspam 0.4
bayes_auto_learn_threshold_spam 10.0
bayes_ignore_to users at spamassassin.apache.org
You will need to setup a bunch of tables as well. See the README
files in the sql directory of the SpamAssassin distribution on how to
setup the database tables.
More information about the MIMEDefang
mailing list