Ledscripts.com
Main Menu
» Main Page
» Priority Support
» Mailing List
» Contract Work
» Contact Info
» Support Forums

Free PHP Scripts
» phpLedMailer
» phpLedAds
» LedFormMail

Free Perl Scripts
» LedNews
» LedAds 2.0
» FullImage

Resources
» Ledscripts.com Blog
» Technical Articles

Other Items
» Online Users (3)

 Spam Filter with SpamAssassin
Back to [ Technical Articles » Perl ]
Published Sep 08, 2005 @ 9:21:31

> Out of my pure hatred for spam, love for qmail/vpopmail/perl, and
> dislike of the complexity of all current 'spam filtering'
> implementations for qmail (and/or vpopmail), I decided to write my own
> perl app to do all the things I wanted (and more) when filtering email.
>
> Using procmail and the standard spamassassin methods required patches
> for qmail (seekable patch) and all kinds of other ridicules setup, and
> then still didn't work with vpopmail (at least I couldn't get it to). So
> I thought, "Why are we hacking up source codes and changing how stuff is
> processed to accomplish this? After all, qmail's mentality is chaining
> programs together to complete the task, so why don't we filter this
> way?"

- Jon Coulter (me), vpopmail mailing list, 8/2/2002
Introduction
Let's face it, spam is a pain. We also have to realize that it likely isn't going to go away any time soon. However, the sociological and technical problems that allow spam are beyond the scope of this article. What I want to do is provide a drop-in spam filter for those of us that use vpopmail (with qmail) using SpamAssassin.

A Little Background
SpamAssassin is a great tool for filtering spam. It is open source, written entirely in perl (almost) and has an active development community that is always updating the software to better filter spam e-mail messages.

The problem with SpamAssassin's default implementation is that it is hard to insert into the qmail stream. Even harder is having per-user settings or filters in an environment like vpopmail. So a couple years ago I wrote a script that would make use of the Mail::SpamAssassin perl module (the core of SpamAssassin) and allow me to customize the configuration at runtime (per-user) and add any additional logic I wanted.

For example, there were situations where I wanted to block every email from a certain domain name, or a subject line that matched a specific regular expression. Neither of this (especially the latter) is possible with SpamAssasin itself. But with this custom script, I'm able to configure many more "not necessarily spam-related" filters, and while I was at it, allow it to be configured on a per-account basis and have it work with vpopmail!

The script itself is written in perl, and the contents of it are to long (and at the same time not very interesting) to include pieces of it specifically in this article. Instead, this article will aim at installing, configuring and using the script. You can download the script at the bottom of the page, under the attachments, and view the source code all you want. Please provide any comments and/or improvements in the forums (link at the bottom of the page).

Continued on the next page...
Page: 1 2 3
Attachments:
» spam-filter.pl [ 10,719 bytes ] [ 1404 download(s) ]

Download this article as a PDF document.
Right Click and Choose "Save As..."

Post comments on this article in the Forums.

Copyright Jon Coulter - Ledscripts.com 2000 - 2005