From Gentoo Wiki
Jump to:navigation Jump to:search

SpamAssassin is email spam filter software maintained by the Apache Foundation and written in Perl.


USE flags

USE flags for mail-filter/spamassassin An extensible mail filter which can identify and tag spam

berkdb Add support for sys-libs/db (Berkeley DB for MySQL)
cron Install a cron job to update SpamAssassin's rules daily.
ipv6 Add support for IP version 6
ldap Add LDAP support (Lightweight Directory Access Protocol)
mysql Add mySQL Database support
postgres Add support for the postgresql database
qmail Build qmail functionality and docs
sqlite Add support for sqliteembedded sql database
ssl Add support for SSL/TLS connections (Secure Socket Layer / Transport Layer Security)
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
verify-sig Verify upstream signatures on distfiles


root #emerge --ask mail-filter/spamassassin



SpamAssassin comes with a number of modules (or plugins) that can be enabled or disabled via configuration files.

  • /etc/mail/spamassassin - Directory containing SpamAssassin modules.

When new plugins appear in a release of SpamAssassin, they are configured in a file named (for example) v341.pre, which corresponds to SpamAssassin v3.4.1 and contains configuration for new plugins as of that version.

A user's local configuration belongs in; however, any file with a .cf suffix (in that same directory) will be loaded by SpamAssassin.

Bayes SQL database

By default, SpamAssassin comes configured to use BerkeleyDB (USE=berkdb) for its bayes database. System administrator's who choose some other database backend (e.g. USE=mysql, USE=postgres, or USE=sqlite) will to configure SpamAssassin to use the alternative database backend before SpamAssassin will run.

Detailed instructions are provided with SpamAssassin and can be found in README.bayes within the SpamAssassin documentation directory (something like /usr/share/doc/spamassassin*/README.bayes).


Spam detection rules

Gentoo's SpamAssassin ebuilds do not include spam detection rules, so these will need downloaded as part of the post-install process. The simplest way to do so is to run the sa-update command.

The SpamAssassin project's GPG key (so that the authenticity of the rules can be verified) must be downloaded and installed:

root #wget -q
root #sa-update --import GPG.KEY

Next download the rules:

root #sa-update

To improve performance it is recommended to compile the spam detection rule set:

root #sa-compile

Automated spam rule updates

The SpamAssassin project regularly releases new and updated rules. It is a good idea to schedule updates (at least) daily, so that the rules are never out of date. A cron job is ideal for this, and newer revisions of the SpamAssassin package supply a cron file. Enable the cron USE flag and re-emerge mail-filter/spamassassin.

See also

Thunderbird — Mozilla's solution to the e-mail client.