Because it is called by Sendmail, Postfix, and Fetchmail upon receiving new emails, Procmail can be used as a powerful tool for combating spam.
This is particularly true when Procmail is used in conjunction with SpamAssassin. When used together, these two applications can quickly identify spam emails, and sort or destroy them.
SpamAssassin uses header analysis, text analysis, blacklists, a spam-tracking database, and self-learning Bayesian spam analysis to quickly and accurately identify and tag spam.
The easiest way for a local user to use SpamAssassin is to place the following line near the top of the
/etc/mail/spamassassin/spamassassin-default.rc contains a simple Procmail rule that activates SpamAssassin for all incoming email. If an email is determined to be spam, it is tagged in the header as such and the title is prepended with the following pattern:
The message body of the email is also prepended with a running tally of what elements caused it to be diagnosed as spam.
To file email tagged as spam, a rule similar to the following can be used:
* ^X-Spam-Status: Yes
This rule files all email tagged in the header as spam into a mailbox called
Since SpamAssassin is a Perl script, it may be necessary on busy servers to use the binary SpamAssassin daemon (
spamd) and client application (
spamc). Configuring SpamAssassin this way, however, requires root access to the host.
To start the
spamd daemon, type the following command as root:
service spamassassin start
To start the SpamAssassin daemon when the system is booted, use an initscript utility, such as the Services Configuration Tool
), to turn on the
service. Refer to Chapter 18, Controlling Access to Services
for more information about initscript utilities.
To configure Procmail to use the SpamAssassin client application instead of the Perl script, place the following line near the top of the
~/.procmailrc file. For a system-wide configuration, place it in