Skip to content

spamassassin config

create user from phpmyadmin and choose to add db of same name and grant all privs on it.

get both userpref_mysql.sql and bayes_mysql.sql templates

http://svn.apache.org/repos/asf/spamassassin/trunk/sql/

wget http://svn.apache.org/repos/asf/spamassassin/trunk/sql/userpref_mysql.sql
wget http://svn.apache.org/repos/asf/spamassassin/trunk/sql/bayes_mysql.sql

userpref_mysql contains an incompatible line for recent versions of mysql, in line 8 replace "TYPE" with "ENGINE". It should read as follows:

) ENGINE=MyISAM;

import both userpref_mysql.sql and bayes_mysql.sql into the spamassassin db created above via phpmyadmin or:

mysql -u root -p -D spamassassin < userpref_mysql.sql

mysql -u root -p -D spamassassin < bayes_mysql.sql

configure /etc/spamassassin/local.cf:

bayes_store_module              Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn                   DBI:mysql:spamassassin:localhost
bayes_sql_username              spamassassin
bayes_sql_password              <password>>
bayes_sql_override_username     amavis
use_bayes                       1
bayes_auto_learn                0
bayes_auto_expire               1
bayes_min_spam_num              150

restart amavis

systemctl restart amavis

train bayes filter with 200 emails of each spam and ham

sa-learn --progress --username amavis --spam <directory full of spam>

sa-learn --progress --username amavis --ham <directory full of ham>

sa-learn --username amavis --sync

force X-Spam header onto all emails to check Bayes is working by setting the following line in /etc/amavis/conf.d/20-debian_defaults:

$sa_tag_level_deflt = -9999;

restart amavis

systemctl restart amavis