Skip to main content

Ralsina.Me — Roberto Alsina's website

Fighting Spam with Qmail (part I)

Well, what the ti­tle says, most­ly :-)

How to in­te­grate qmail and spa­mas­sas­s­in, so your mail gets fil­tered, try­ing to keep it sim­ple.

Steven De Boeck / 2006-04-03 04:57:

Just one small comment. The ifspamh script doesn't appear to be a perl script but a shell script. By default, it is executed by ksh (#!/bin/ksh at top of script).



cheers,



steven

James R Grinter / 2006-04-03 04:57:

I was just going to say the same thing - I wrote it as a shell script to make it quicker to fire up - the whole idea being to avoid running a new Perl for each and every SpamAssassin check.



It will actually run under sh or bash as well as ksh - and works best with an implementation that has a built-in printf (just run 'type printf' at your shell prompt if you're not sure.)

Roberto Alsina / 2006-04-03 04:58:

I'll fix it. In fact, now I remember I had to install pdksh to make it work ;-)



I wonder where I got that perl idea.

Arno Slatius / 2006-04-03 05:02:



Start redirecting any misclassified mail to the obvious address. Make sure you redirect it unchanged! usually, the "forward" feature of your mailer won't be good enough, since it will appear that the spam comes from you, and you don't want your own mail to be classified as spam, right? ;-)





I like this idea, but how do you get a mail client to redirect a mail unchanged? Especially outlook, which most users tend to use?

Roberto Alsina / 2006-04-03 05:03:

One way to do it is having a spam folder in your email server, and then just move the mails to that folder, then have spamassassin read all those folders. Can be a lot of work, though.



If you have a IMAP server with public folder support, then you can use that. It also has the advantage of being safer than a public spam@... address.



If none of that can be done, it is up to your email client. AFAIK, Outlook Express doesn't have a way to do this. Others do, and it's usually called "Bounce" or "Redirect" in the menus.

Malte Hübner / 2006-04-03 06:34:

I just created 3 different imap-dirs. one in which spam-assassin puts spam and two other from which spamassassin will learn (cronjob). so you just have to move spam which was not cought by sa to your spam-learn dir. for no-spam the same. just use drag-and drop in your mail-client.

Nico Nijman / 2006-04-03 06:45:

All works fine, but I am looking for a way so that spamassassin won't check outgoing messages, it makes my PHP scripts so slow... Anybody got some ideas?

Eric. / 2006-04-03 06:45:

Hi,



I know nothing about sh / ksh but would really like to see the software trigger on on X-Spam-Flag but on X-Spam-Level depending on the "*" rating.

That way, I could rewrite with subject_tag for, let's say all email with score between 6 (required_hits) and 12 and send them to a "sure spam" folder for anything above 12.

Must be trivial, it's just I don't know how to do the test ;-)



Thanks to anybody replying ...

Rolf Ernst / 2006-04-03 06:46:

I have set up all files *exacty* as described. Indeed, spam is being identified as shown by the maillog. However, after identifying I see the following message:



qmail: 1081953141.258573 starting delivery 7636: msg 2998483 to local 14-rolf.ernst-spam@24hourloop.com



Apparently qmail wants to send it to another user called rolf.ernst-spam. If this is how it has to be, I guess I could live with it.



However, is there a way to send it to a subfolder of rolf.ernst called 'spam' (or .spam)?



/re

Roberto Alsina / 2006-04-03 06:59:

Sorry for the *very* late reply: yes, that´s how it works. So, the .qmail-spam file in rolf´s home directory redirects rolf-spam´s mail to the spam subfolder like this:



./Maildir/.spam/



Assuming you are using a IMAP server that stores subfolders that way.

Roger Harrell / 2006-04-03 07:00:

Tried this script, but do not have ksh installed so I tried changing the first line to /bin/sh.



When mail is received it is processed to Maildir, but it is not going through spamassassin at all. Mail comes through unchanged. no x-spam headers, no flag, nada. Thoughts? Or do I just need to install pdksh.



Thanks,

Roger

Roberto Alsina / 2006-04-03 07:01:

Roger: I assume you did modify the .qmail file for your user.



If you did, we'll need to check some logs.



Please email me (small envelope thingie on the article's page).


Contents © 2000-2024 Roberto Alsina