A quick guide on filtering email with procmail and spamassassin

There are more complete directions below, but to setup the second example automatically, simply run /usr/local/bin/spamfilter.sh from the shell prompt for your account.

Like so:

bash-2.05b$ /usr/local/bin/spamfilter.sh
Done!
bash-2.05b$

However, if you wish to know more:

The first stop is to create a .forward file that causes your .procmailrc file to be used.
echo "\"|IFS=' ' && exec /usr/local/bin/procmail -f- || exit 75 #filter\"" > \
.forward
After that, you can create a .procmailrc file. A file that will simply tag possible spam messages would be something like:
(example .procmailrc)
VERBOSE=on
MAILDIR=$HOME/mail
DEFAULT=/var/mail/${USER}
LOGFILE=${MAILDIR}/log
FORMAIL=/usr/local/bin/formail
SENDMAIL=/usr/sbin/sendmail
BLOCKFOLDER=${MAILDIR}/spam.blocked

# Call SpamAssassin
:0fw
| /usr/local/bin/spamc

# save to normal spoolfile
:0
$DEFAULT

A slightly more advanced .procmailrc example that will move spam messages to a folder called "spam.blocked" would be:
VERBOSE=on
MAILDIR=$HOME/mail
DEFAULT=/var/mail/${USER}
LOGFILE=${MAILDIR}/log
FORMAIL=/usr/local/bin/formail
SENDMAIL=/usr/sbin/sendmail
BLOCKFOLDER=${MAILDIR}/spam.blocked

# Call SpamAssassin
:0fw
| /usr/local/bin/spamc

# Save spam to another folder
:0:
* ^X-Spam-Status: Yes
$BLOCKFOLDER

# save to normal spoolfile
:0
$DEFAULT

Advanced documentation about SpamAssassin configuration is available at spamassassin.org. You would place these directives in a file "~/.spamassassin/user_prefs" .