create new tag
, view all tags

Email with Spam Control using Mutt, Procmail, and Spam Assassin

Brian Reichert describes how he set up email on his Linux system with spam filtering at least as good as what he had working under Windows.


See also:

  • EmailOverviewSketch
  • EmailServerSketches
  • Do a WebSearch on email, procmail, spam assassin, mutt, fetchmail, and similar terms (you may not get hits on all of them), and generally ignoring those pages prefixed with Csic as those are more Windows oriented




I've only been using Linux as my main OS for about a year or so. When I made the change from Windows one of my requirements was to have spam filtering that was at least as good as what I had working under Windows. When I started looking into meeting this goal I found there wasn't one all encompassing source to get what I wanted done so I spent many hours Googling about the Net and asking questions on mailing lists. Doing this was kind of an annoyance and, if I wasn't such a stubborn guy and stuck it out, I may have never switched to Linux at all.

The purpose of this entry is two-fold, one is to consolidate all this info into one place in case I need to look it up in the future. The other is maybe someone who is new to this will stumble on my page and be saved a bunch of time and effort.

I'm not going to write anything new or profound here. No sense re-inventing the wheel since the other sites I'll reference are better written than I think I could do.


Here are the tools I use for spam control:

  • Mutt - An E-mail client.
  • Procmail - A rules based mail processor that sorts inbound mails into mailboxes.
  • SpamAssassin - A score based spam detection program.
  • Vipul's Razor - A collaborative database of spam, used by SpamAssassin to better detect spam.


First, before I could even think about killing spam I had to get my E-mail working with mutt. One thing that screwed me up for a while was trying to send mail from mutt until I was told that, unlike Outlook, mutt didn't have it's own built in SMTP server. Most Linux distributions come with the sendmail MTA (Mail Transfer Agent) and I think it will "just work" but I chose to install qmail as my MTA. If you want to go to that extent you can use Life With qmail to get it all setup.

OK, once the MTA is working all you need to do is configure mutt to work. That sounds simple enough when you read it but it was actually the hardest part for me. To get E-mail flowing takes multiple programs, and it can get very confusing. The sources I used for getting mutt to work are here and here. The second reference there is just a list of someone's working config files which doesn't sound like much but I found it useful to see what working settings looked like. And don't forget mutt's site for FAQ's and links to other documentation. There's plenty there.

In a nutshell, without making this longer than it needs to be, I use fetchmail to actually get the mail, which passes it to procmail, which sorts it into mailboxes, then mutt views it. Spammassassin gets called from procmail.

As far as procmail goes, I fully admit I don't know enough to say much about it, so I used The Procmail Quick Start to get me going. This is not a short read by far, but it's well written and has a section geared specifically toward using Procmail with SpamAssassin. It'll tell you just what to do with great explanations and examples. First I'd just read the quick start to learn about procmail, then go into setting up SpamAssassin.

Once you are familiar with procmail read the Top-Level Install File at www.spamassassin.org. The easiest is to install using the CPAN instructions at the top. It's pretty detailed, but once I got it installed, I pretty much just followed The Procmail Quick Start to get me going. In a nutshell, what happens is procmail passes the message to SpamAssassin which analyzes it and adds some new header info such as the number of hits (hits are the number of "spammy" things it find) and whether it considers it spam or not. You use these new headers in your procmail recipes to filter out your spam.

Once procmail and SpamAssassin are happy, that is tested and working, it's time to install Vipul's Razor. To quote their site:

Vipul's Razor is a distributed, collaborative, spam detection and filtering network. Through user contribution, Razor establishes a distributed and constantly updating catalogue of spam in propagation that is consulted by email clients to filter out known spam. Detection is done with statistical and randomized signatures that efficiently spot mutating spam content. User input is validated through reputation assignments based on consensus on report and revoke assertions which in turn is used for computing confidence values associated with individual signatures.

The Razor simply adds more tests and increases the accuracy of your spam detection. There's no need to modify any procmail rules. SpamAssassin should use Razor automatically. If it doesn't you may need to recompile it. The instructions are very clear and nice. Follow them exactly and it will work fine.

As a side note, you may want to look into using clamassassin along with clamav to sort out any viruses you may get. Even though 99.999% of them will not work on any *nix system I think it's just a good idea to be able to tell someone you know they have a virus. Think of it as being a good netizen.

Also, if you are forced to use Windows thus ruling out any of the stuff I've been talking about you can look into Cloudmark which is essentially SpamAssassin+Razor for Windows. The only down side is Cloudmark requires a subscription. If you don't want to pay an annual subscription then you may want to check out Mailwasher. Mailwasher is rules based, meaning it only knows what you tell it so it's not as effective as SpamAssassin+procmail but once you get it trained it's pretty good. Before I switched to Linux Mailwasher was my spam control of choice.

Well, that's it. All of the info I've gathered and personally used to get this stuff going having no experience with any of it before starting. I can say that well over 90% of the spams I get are filtered into my spam directory with precious few false positives. This entire process was a lot of work for me to figure out, especially being totally green. But, now that it's all done, I can't see doing it any other way.

I've tried to be as accurate as I can. If you find anything wrong please let me know.

Note: This entry originally appeared on my blog. I hope that having this here will get it before more eyes than my humble site could.


  • (br) BrianReichert - 24 Nov 2004
  • (rhk) RandyKramer - 24 Nov 2004 (minor editing)
  • If you edit this page: add your name here; move this to the next line; and if you've used a comment marker (your initials in parenthesis), include it before your WikiName.

Revision Comment

  • %DATE% —
r1.5: set PageStatus to First Draft -- I thought I had done that, if so, it
somehow reverted to Scribbles (rhk)
r1.4: added / revised summary, added cross references ("See also") (rhk)
r1.3: minor editing (rhk)
r1.2: first issue (br)
r1.1: blank template (rhk)

Page Ratings

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r5 - 2004-11-25 - RandyKramer
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by PerlCopyright 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WikiLearn? WebBottomBar">Send feedback
See TWiki's New Look