Filtering Spam with Procmail
Pages: 1, 2
I'd also like to show how to configure spam bouncer. Since I tested
both of these programs on a single-user machine, I removed the lines
from my .procmailrc that I had added to configure junkfilter before I installed spam bouncer. I then became the superuser and proceeded
with the build:
su
Password:
cd /usr/ports/mail/spambnc
make install clean
exit
|
Related Reading
|
At the very end of this build, you'll receive a message telling you
that the rules were installed into /usr/local/share/spambnc and that you
should read /usr/local/share/doc/spambnc/documentation.html. Unlike
junkfilter, spam bouncer doesn't have a global configuration file;
instead, you add configuration options to your .procmailrc. You really
should read that suggested documentation file to see which options are available
to you as I won't cover them all here.
I found that spam bouncer had a few additional filtering features
that I liked. For example, by default, it will filter out all emails written
in Chinese, Japanese, Korean, Russian and Turkish. If you don't use these
languages, any correspondence in them will probably be spam. However,
if you happen to use one of those languages, don't forget to change the
default "no" to "yes" for your particular language so spam bouncer won't
filter out all of your email.
If you want to be more aggressive in your filtering of spam, you can
configure spam bouncer to check a variety of Internet sites that keep
lists of known spammers and relays. By default, these checks are turned off.
Before enabling these checks, visit the relevant sites to ensure they
are still in operation and to register if it is required. The sites listed are:
- dorkslayers
- MAPS (Mail Abuse Prevention System) Dial-up User List
- ORBZ (Open Relay Blackhole Zones)
- The Open Relay Database
- OsiruSoft's Open Relay Spam Stopper
- The Spamhaus Project
Even if you decide to leave these checks off, the mentioned sites do contain interesting reading.
To configure spam bouncer, you'll have to add these two lines to your
.procmailrc to tell procmail to call spam bouncer:
SBDIR=/usr/local/share/spambnc
INCLUDERC=${SBDIR}/sb.rc
Note that the INCLUDERC line should be the very last line in your
variable section, meaning it should be just before your own filtering recipes.
You'll also need to tell spam bouncer where to put the messages it
filters out. The spam bouncer utility has two variables for this: the
first tells it where to put messages that might be spam, and the second
tells it where to put messages that are pretty well guaranteed to be spam. I set
up my two variables like this:
BLOCKFOLDER=$MAILDIR/garbage
SPAMFOLDER=$MAILDIR/spam
and placed them just before the INCLUDERC line.
Once you've set those four required variables, spam bouncer is ready to
roll. There are several dozen other variables I haven't mentioned that
might pique your interest enough to include in your own .procmailrc file;
see that documentation file for details.
If you're subscribed to any mailing lists, you'll soon find that some
mailing lists are caught and flagged by spam bouncer, while others
survive the spam bouncer checks and make it to your own filtering recipes.
For example, all the mail from the freebsd questions list was being placed
in my garbage folder instead of my questions folder, yet the messages from
most (not all) of the securityfocus mailing lists made it to my security
folder.
To tell spam bouncer not to filter a message just because it came
from a mailing list, create a file in your home directory called legitlists.
In that file, put the address of each mailing list you're subscribed to on one
line; mine looks like this:
questions@freebsd.org
freebsd-questions@freebsd.org
security@freebsd.org
advocacy@freebsd.org
newbies@freebsd.org
sectools@securityfocus.com
newsscan@newsscan.com
After about a week or so of adding rogue lists to this file as you discover them, you shouldn't have any more trouble with mailing lists messages being blocked just because they came from a mailing list. However, virii and spam sent to those mailing lists will continue to be filtered out, which is probably what you were aiming for.
Another file you may want to create in your home directory is called
.nobounce. If you have friends that send email from known spammer
domains such as hotmail.com, put their addresses in this file, one
address per line. This will tell spam bouncer that you trust that particular
email address to not send you any spam.
I hope the last two articles helped to get you started on the
possibilities of using procmail. If you want additional information
on either junkfilter or spam bouncer, check out their related Web
sites:
In the next article, I'll let you in on the results of my latest tour through the ports collection.
Dru Lavigne is a network and systems administrator, IT instructor, author and international speaker. She has over a decade of experience administering and teaching Netware, Microsoft, Cisco, Checkpoint, SCO, Solaris, Linux, and BSD systems. A prolific author, she pens the popular FreeBSD Basics column for O'Reilly and is author of BSD Hacks and The Best of FreeBSD Basics.
Read more FreeBSD Basics columns.
Return to the BSD DevCenter.
