Anti-Spam

From GreyWiki

Jump to: navigation, search

Contents

Qmail SMTP

Stopping spam at the SMTP border is rather nifty, wouldn't you say? This patch, designed to block email receipt for nonexistent account names, does a great job so far although it requires a bit o' setup. (Documentation to follow...)

SpamAssassin Rules Updates

Did you know about the 'sa-update' command?

Neither did I.

SpamAssassin and Mailfilter

Coupling SpamAssassin with Mailfilter, we acquire the ability to file messages based on score either into a designated "maybe spam" folder or directly into the trash. We're also only running messages of about 256k or smaller through SpamAssassin in an attempt to avoid having large messages kill the server.

Here's the relevant portion of the ~/.mailfilter file:

if ($SIZE < 262144)
{
xfilter "/usr/bin/spamc"
}

# If it has a score of 9 or more "stars" then it goes away.
if (/^X-Spam-Level: *---------.*$/)
{
# Not needed, it's going away for good
# cc |/usr/bin/sa-learn --single --spam
to "/home/greyduck/Maildir/.Trash"
}

# If it has stars, but not as many as 9, it goes into the Spambucket.
if (/^X-Spam-Level: *-.*$/)
{
to "/home/greyduck/Maildir/.Spam"
}

# I don't think I want automatic "ham" just because SA didn't catch something. Bah.
# cc |/usr/bin/sa-learn --single --ham
to "/home/greyduck/Maildir/"

This technique relies upon non-asterisk scoring markers. Here's the /etc/mail/spamassasin/local.cf to make that happen:

report_safe 1
always_add_headers 1
add_header all Level _STARS(-)_

Also, the ~/.qmail file should read:

| /usr/local/bin/maildrop

(One should ensure the correct path to maildrop, of course.)

Related Documents

See SpamAssassin on MySQL for how we created a web-enabled SpamAssassin/SquirrelMail rig.

Personal tools