Configuring Procmail for SpamAssasin

Written by M. W. Chang on 24-June-02.
Date: 16 July, 2002

I would assumed you or your distribution installed procmail and sendmail properly.

Fire up Perl's CPAN shell as per the README file in doc dinstall Mail::SpamAssassin

# perl -MCPAN -e shell
cpan> o conf prerequisites_policy ask
cpan> install Mail::SpamAssassin
cpan> quit

You may need to update your perl first. Just follow the instructions and answer the questions with default answer (press ENTER).

If everything went well, you should able to fire up SpamAssassin.  Let's check it's online help:
# spamassassin -h
# man spamassassin

By default (for my Caldera Openlinux 3.1), the config file for SpamAssassin is /etc/mail/spamassassin/ But you can always overide this with

# spamassassin -a /path/to/

How does SpamAssassin work? When it was passed a message from the stdin, it would make a call to a remote site which contains a list called Realtime Black List (DNSBL) with the sender's email address in the message. If the
sender's email address was in the DNSBL, it would add a RFC822 modifier to the message "X-Spam-Status:" and set it to "Yes".

Now that the spamming messages was tagged, you can use procmail or whatever mail processor to remove it easily.

create /etc/procmailrc:

# you need a file ~/.forward with the following line:
# "|exec /usr/bin/procmail"
# user-specific procmailrc is ~/.procmailrc
# to run procmail for all users
# 1. create /etc/procmailrc
# 2. touch /var/log/procmail
# 3. chmod 666 /var/log/procmail
# 4. make sure that /var/log/junkmail is created
# references:
# the link features a simplified how-to of Nanay, plus a link
# to grep tutorial
# Next may be needed if you invoke programs from your procmailrc
# Details in Check Your $SHELL and $PATH in Troubleshooting below

# Directory for storing procmail configuration and log files
# You can name the environment variable MDIR anything you like
# or, if you prefer, don't set it (but then don't refer to it!)

# Put ## before LOGFILE if you want no logging (not recommended)

# To insert a blank line between each message's log entry,
# uncomment next two lines (this is helpful for debugging)

# Set to yes when debugging
# Remove ## when debugging; set to no if you want minimal logging


# simplest rule for testing
* ^Subject:.*test
LOG="test: "

# if you want to use your own conf file
# -c /etc/mail/spamassassin/
| /usr/bin/spamassassin -P
* ^X-Spam-Status: Yes
# all un-touched mail to go back to the user's own mbox by default

searchSearch Index