SpamAssassin is an anti-spam mail filter.
Additional Resources:
Note: This chapter only installs SpamAssassin and Razor. We will configure Exim, the MTA, to use SpamAssassin as a filter in a subsequent chapter.
# apt-get update
# apt-get install libnet-dns-perl libmailtools-perl
[screenshot]
Note: These packages improve the performance of SpamAssassin, but they are not required.
# apt-get install --target-release testing razor
[screenshot]
Note: Razor improves the performance of SpamAssassin, but it is not required.
# apt-get install --target-release testing spamassassin
[screenshot]
# mysql < spamassasin-userpref.sql
[screenshot]
# mysql
[screenshot]
Notice how the command prompt changes from "#" to "mysql>".
mysql> SHOW DATABASES;
[screenshot]
The spamassassin database should appear in the list.
mysql> USE spamassassin;
[screenshot]
The spamassassin database should appear in the list.
mysql> SHOW TABLES;
[screenshot]
The userpref table should appear in the list.
mysql> SELECT * FROM userpref;
[screenshot]
mysql> GRANT SELECT ON spamassassin.* TO spamd@localhost IDENTIFIED BY 'def456';
[screenshot]
This command creates a MySQL user named spamd with password def456 that has read-only access to all tables in the spamassassin database.
Note: Use a different password than def456.
Note: The password must be given within single quotes.
Note: The MySQL accounts database is separate from the domain. Domain users cannot login to MySQL.
mysql> exit
[screenshot]
Notice how the command prompt changes back to the "#".
# mysql -h localhost -u spamd -p
[screenshot]
mysql> SELECT * FROM spamassassin.userpref;
[screenshot]
mysql> exit
[screenshot]
Notice how the command prompt changes back to the "#".
# adduser --system --home /var/lib/spam --shell /bin/false --disabled-password --disabled-login spamd
[screenshot]
# mcedit /etc/spamassassin/local.cf
[screenshot]
Change the file to read as follows:
auto_whitelist_path /var/lib/spam/whitelist user_scores_dsn DBI:mysql:spamassassin:localhost user_scores_sql_username spamd user_scores_sql_password def456 user_scores_table userpref
Remember to substitute the appropriate password for def456.
# mcedit /etc/default/spamassassin
[screenshot]
Change the file to read as follows:
ENABLED=1 OPTIONS="--username spamd --nouser-config --sql-config --whitelist"
# /etc/init.d/spamassassin start
[screenshot]
# zcat /usr/share/doc/spamassassin/sample-spam.txt.gz | spamc | more
[screenshot]
SpamAssassin is working properly if this line exists in the output:
X-Spam-Status: YES
(This is the 9th line in the screenshot.)