SpamAssassin is a rule-based mail filter that identifies spam. It uses a wide range of heuristic tests on mail headers and body text to identify spam.
SpamAssassin filtering is configured on two levels:
- Server-level configuration is done by Plesk administrator.
- Mail directory-level configuration is done by users for specific mail directories.
At the server level, you (as a Plesk administrator) can enable or disable any of these two types of filters. Thus, there are four possible situations:
- No filtering is applied, when spamd daemon is not running:
- both filters are disabled by the Plesk administrator.
- the personal filter is disabled at the mail directory level.
- Filtering is applied at the server level only.
- Filtering is applied at the mail box level only.
- Filtering is applied at both levels.
When both filters are enabled for a specific mail name, a combined filter is created for the corresponding mail directory. When processing messages, SpamAssassin calculates the number of hits according to its internal rules. A message is considered to be spam if the number of hits exceeds the established threshold, which is set to 7 by default. You can change the threshold in Plesk. White and Black lists can be considered special rules, which assign constant hit rates to messages conforming to mail address patterns in these lists:
If the message source address conforms to the Black list, the message gets +100 hits by default.
If the message source address conforms to the White list, the message gets -100 hits by default.
Sometimes, a message matches both Black and White lists. In that case, it has +100-100=0 hits.
If the message destination address is included in the server-wide ignore list, then all messages to this address will go directly to the addressed mail directory.
At the server level, you can configure SpamAssassin to mark messages with a special string if they are recognized as containing spam. At the mailbox level, you can make SpamAssassin delete or mark the message if it is considered as spam.
Starting from Plesk 9.x, the maximum message size to filter is hardcoded in the spam handler and set to 256KB. This value provides normal server loading. Since the SpamAssassin service consists of perl modules, they may result in a heavy server load when processing long messages.
You can get more information on SpamAssassin at spamassassin.apache.org
The SpamAssassin configuration is stored in the spamfilter and spamfilter_preferences tables of the psa database. You can manage it with the $PRODUCT_ROOT_D/admin/bin/spammng utility. It displays help if started without any options.
Server-wide SpamAssassin settings are stored in the following files:
The /usr/share/spamassasin/*.cf files contain configuration details, e.g. White list and Black list scores are assigned in the 50_scores.cf configuration file.
The /etc/mail/spamassassin/local.cf stores server-wide filter settings.
When Plesk works with virtual mail users (not real system users with UIDs)
spamd is executed with keys showing where to find the configuration files of virtual users:
User settings are stored in the following files:
/var/qmail/mailnames/<domain>/<mailname>/.spamassassin/user_prefs file defines SpamAssassin actions.
/var/qmail/mailnames/<domain>/<mailname>/.qmail defines how message flow reaches SpamAssassin daemons.
If the message destination address is included in the server-wide ignore list then all messages to this address will go directly to the addressed mail directory. For example, if you include email@example.com in this list, then the .qmail file will look like this:
# cat /var/qmail/mailnames/domainXX.tst/mailuser/.qmail | /usr/local/psa/bin/psa-spamc accept | true | /usr/bin/deliverquota ./Maildir
If SpamAssassin filtering is allowed then the following command allows the mail to go through the spam filter first and then to the mailbox added to this file:
| spamc -f -u admin@domainXX.tst|maildir ./Maildir/
You can find examples of spam-like and no-spam messages in: