procmail - You can configure your account manually to use procmail
to filter your email. Procmail is extremely powerful
and a treatise on using procmail is certainly beyond the scope of this FAQ.
However,
here is a cookbook example of how to drop all incoming email from spam.com and
all email classified as spam by PureMessage with a 70% probability or higher
using the X-Perlmx-Spam header into
a file called spamfolder in your ~/Mail directory.
First, you must create a .procmailrc file in your home directory that contains
a set of rules you wish to apply to your incoming mail. For this example, we
create a file that contains the following:
MAILDIR=$HOME/Mail
LOGFILE=$MAILDIR/procmail.log
# File anything from spam.com into spamfolder
:0:
* ^From.*@spam.com
spamfolder
# File messages with 70+% spam probability into spamfolder
:0:
* ^X-Perlmx-Spam:.*Gauge=XXXXXXX
spamfolder
The first rule (frequently called recipes in procmail) tells procmail to file any email from spam.com into a file
called spamfolder. The second rule does the same for email with a matching
X-Perlmx-Spam header with 70% or greater spam probability.
If you want to just delete the email
instead of saving it to a file, simply replace "spamfolder"
with "/dev/null" in the above example.
Next, create a .forward file in your home directory that invokes procmail. Simply
create a .forward file using your favorite editor that contains the following line:
"|IFS=' '&&p=/usr/local/bin/procmail&&test -f $p&&exec $p -Yf-||exit 75 #username"
where you replace "username" with your username.
If you found that email from your friend at somefriend@gooddomain.com was incorrectly
being identified as spam, you could add the following as the first rule to
your .procmailrc to send it to your normal mailspool before it is matched against
the other rules.
# Deliver email from somefriend@gooddomain.com to the inbox
:0:
* ^From.*somefriend@gooddomain.com
/var/mail/username
where you would replace username with your username.
If you wanted to forward all non-spam email off to a non-CS account instead
of delivering it locally, you can do this by adding the following rule to the
end of your .procmailrc.
# Forward email off to somename@somedomain.com
:0
* !^FROM_MAILER
! somename@somedomain.com
where you would replace somename@somedomain.com with the
email address to which you wanted your email forwarded. The
test that the email is not from the mailer daemon (!^FROM_MAILER)
is critical to prevent mail loops in the event the forwarding
address fails.
You can also key on "[SPAM: #" that PureMessage adds
to the Subject line.
For example, if you
wanted to automatically refile any message that had this
spam tag in the Subject: line, you could use:
# Send anything with [SPAM: in the Subject: to spamfolder
:0:
* ^Subject:.*\[SPAM:
spamfolder
Currently PureMessage only adds the SPAM tag to the subject line of
messages that are above a spam probablility of 60%. If you also
want to add the SPAM tag to messages in the 50-59% probability
range, you can do this with the following procmail recipe:
# Add the SPAM tag to the Subject: for messages with spam probability between 50-59%
:0:
* ^X-Perlmx-Spam: Gauge=XXXXX
* !^Subject:.*SPAM:
{
SUBJ=`formail -c -xSubject:`
:0 fhw
| formail -c -I"Subject: [SPAM:# 50%] $SUBJ"
}
Another common thing people want to be able to do with spam is reject
it outright (ie. bounce it) instead of silently filing it into a folder
or throwing it away. In most cases, the spammer will never see the
bounce but it may be useful if a real, non-spam message gets tagged as
spam since the originator of the email will get a bounce message saying
it couldn't be delivered. In order to do this with procmail, you set
a non-zero exit code that causes sendmail to sense a failure in the
delivery which causes the bounce. There are only a limited number of
exit codes and associated messages available, with 69 (service unavailable),
67 (addressee unknown), and 65 (data format error) being a few of the
commonly used exit codes. Here is an example that uses the exit code
to bounce spam email with 'service unavailable' but also save a copy
(unbeknownst to the spammer!) into your spamfolder.
# Bounce email that has 70+% spam probability, but also save a copy in spamfolder
:0
* ^X-Perlmx-Spam:.*Gauge=XXXXXXX
{
EXITCODE=69
LOG="SPAM rejection - "
:0:
spamfolder
}
For more the details, see the procmail, procmailrc, and procmailex man pages.