[kde-linux] Kmail and bogofilter

Thierry de Coulon tcoulon at decoulon.ch
Fri Aug 12 21:40:58 UTC 2005


On Friday, 12 August 2005 17:31, Christophe Gaubert wrote:
> 	Hi every one,
>
> I'm using kmail on KDE 3.3.2 with a pop3 account. I have installed
> bogofilter to help me against the spam. My question : do I have to
> learn what is spam to bogofilter (by running some command lines on my
> mails), or is it enough to mark mail as spam within kmail ? For now,
> every mail has the spamicity score equals to 0.52. So it isn't very
> helpful.
>
> Thanks in advance.
> Christophe

Hello,

From your name I'd guess you speak French. So di I, However, as this might be 
usefull for others, I'll write in English.

I've been using Bogofilter for months and I'm very satisfied.
Now setting it up was a bit complicated. I hope I can reconstruct the process. 
If it does not work tell me so that I can correct this "how-to".

1. obviously, first install bogofilter

2. You must now set up filters in kmail. From my setup up it should be the 
following:

the first filter is called "bogoheader" and contains:
Filter Criteria:
Match all of the following: <any header>     matches regular expr.     .*
Filter Actions:
remove header  X-Bogosity
remove header  X-Attachments

Apply this filter to incoming messages (I also apply it manualy, actually)

The second filter is called "bogofilter" and contains:
Filter Criteria
Match all of the following: <any header>         matches regular expr.      .*

Filter Actions
pipe through        bogofilter -epv


The third filter is called "bogofilter_is_spam" and contains:
Filter Criteria
Match all of the following: X-Bogosity contains  YES

Filter Actions
file into folder  <choose your folder for spam files>
mark as           <choose>

If I recall correctly, the first filter removes any headers that would come 
with the mail, the second checks the mail with bogofilter and the third one 
files the mails considered as spam where ever you want.

Now, you should create two folders in kmail: spam and NonSpam. In the next 
time, put any mail bogofilter does not catch, but you consider to be spam in 
the folder "spam". Put any example of "good" mail in "NonSpam". During the 
first days, you'll see that quite a lot of spam-mails get through, it's 
normal. Once you have, say, 100 spams in "spam", open a console (as user) and 
run ./bogolearn.sh

This is a shell script that will analyse the examples of spam found in "spam", 
and the examples of good mails found in "NonSpam", and improve bogofilters 
knowledge of you mails. Repeat this a few time and you should be happy.

I get 100 - 200 mails a day (being on several mailing lists) and usually get 
no more than 2-3 spam in my "inbox". What's most important, I never had a 
single false positive in over a year and a half service from bogofilter.

I don't remember if bogolearn.sh was created during installation. In case it 
is not copy this to a textfile, save it and make it executable:

#!/bin/sh
# train bogofilter with new spam and non-spam
BOGOFILTER="/usr/bin/bogofilter";
MAILDIR="/home/thierry/Mail"
GOODDIR="NonSpam/cur";
SPAMDIR="spam/cur";
GOODLIST="goodlist";
SPAMLIST="badlist";

cd $MAILDIR/$SPAMDIR;
echo Spam:
for i in *; do
if [ -z "`grep -e " $i " $MAILDIR/$SPAMLIST`" ]; then
echo Processing Mail ID \#$i;
bogofilter -s -v < $i ;
echo " $i " >> $MAILDIR/$SPAMLIST;
fi
done;

cd $MAILDIR/$GOODDIR;
echo NonSpam:
for i in *; do
if [ -z "`grep -e " $i " $MAILDIR/$GOODLIST`" ]; then
echo Processing Mail ID \#$i;
bogofilter -n -v < $i ;
echo " $i " >> $MAILDIR/$GOODLIST;
fi
done;

I wanted to add three snapshots to make my explanations a little more 
understandable, but this seems to make the message too big. If you need them, 
send me a private e-mail and I send them directly.

Good luck

Thierry




-- 
The problem with the world is stupidity. Not saying there should be a
capital punishment for stupidity, but why don't we just take the
safety labels off of everything and let the problem solve itself?
Frank Zappa





More information about the kde-linux mailing list