I’ve recently changed the config of my spamassassin and just now noticed that the SPAM folder in my inbox is empty. So what has happened? When changing the config of spamassassin from file to database I only did the half thing. So spamassassin/amavis got stuck with a mixed config and did the default thing: delete spam immediatly. Although I don’t have missed a mail (at least I don’t know of any mail I missed) I prefer having spam mails put in the spam box over deleting them.
So here is the whole thing which I found at http://technology.mattrude.com:
1. Create a database for spamassassin config
If not done already create a database eg
spamassassin with a user spamassassin and a password.
Then we need to create some tables to store the configuration and store the default configuration in it. If you like you can copy my configuration:
Either import the file using phpmyadmin or on the commandline:
mysql -h localhost -u spamassassin -pspamassassin.pw < spamassassin.sql.txt
If you have a look in the table
userprefs you will note several entries for the user
@GLOBAL. These are the default entries for all users. You might want to adjust them to fit your needs.
2. Tell spamassassin to use the database
/etc/mail/spamassassin/local.cf. It needs the information for database access. And it makes sense to give some more default settings. If for some reason the database is not accessible for spamassassin it will use these defaults.
##DB Settings## user_scores_dsn DBI:mysql:spamassassin:localhost user_scores_sql_username spamassassin user_scores_sql_password spamassassin.pw auto_whitelist_factory Mail::SpamAssassin::SQLBasedAddrList user_awl_dsn DBI:mysql:spamassassin:localhost user_awl_sql_table awl user_awl_sql_username spammassassin user_awl_sql_password spamassassin.pw bayes_store_module Mail::SpamAssassin::BayesStore::MySQL bayes_sql_dsn DBI:mysql:spamassassin:localhost bayes_sql_username spamassassin bayes_sql_password spamassassin.pw ##Defaults settings as fallback## required_score 5.0 rewrite_header Subject [SPAM] tag_level_deftl -99 kill_level_deflt 99 trusted_networks 192.168.1.0/24 report_safe 1 use_bayes 1 bayes_auto_learn 1 skip_rbl_checks 0 use_pyzor 1 use_razor2 1 razor_config /var/lib/amavis/.razor/razor-agent.conf use pyzor 1
The last three lines only make sense if you are using
3. Adjust spamassassin’s startup options
In order to use the database spamassassin needs to start with the correct options. As it’s not the best idea to edit the startup script
/etc/init.d/spamassassin we better use
/etc/defaults/spamassassin as suggested in the comments.
OPTIONS="-d -m5 -x -q -Q -u nobody"
and restart spamassassin and amavis.
/etc/init.d/spamassassin restart /etc/init.d/amavis restart
Check if everything is ok:
ps -eaf |grep spamd
4. Remove unnecessary options
Not to forget: if you have put any options to
/etc/amavis/conf.d/50-user these will override any settings in the database. Just comment or remove them and restart spamassassin and amavis (again).
Now wait for the next spam mail to check if everything is working the way it should. Of course there will be now spam if you need it once in a livetime!