[Bogofilter]Some automatic handling driving from Nigel filer set

Daniel Moyne daniel.moyne at neuf.fr
Fri Aug 22 14:24:15 CEST 2008


Following Nigel's how-to and philosophy I am now using "cron" to automatically 
handle bogofilter actions off KMail.

Recall :
. "Spam" folder contains manually handled messages of spam type  ; mainly used 
at the very beginning to start training bogofilter and then each week through 
cron automatic action.
. "NonSpam" folder contains manually handled messages of ham type  ; mainly 
used at the very beginning to start training bogofilter and then each week 
through cron automatic action.
. bogofilter filtering is piping messages to "inbox", "spam" or "unsure" 
folders depending of recognized type (spam, ham or unsure) ; all these folders 
but "inbox" folder have a 30 expiration period.
. it is up to the user to check from time to time :
- content of "inbox" folder to move spam messages not correctly detected to 
"Spam" folder,
- content of "spam" folder to move ham messages not correctly detected to both 
"inbox" and "NonSpam" folders,
- content of "unsure" folder to move spam messages not correctly detected to 
"Spam" folder and ham messages not correctly detected to both "inbox" and 
"NonSpam" folders.

From there on training of bogofilter on "Spam" and "NonSpam" folders is 
automatically handled through a cron action each week by executing the 
following script (I used Kcron to set this action) called 
"training_bogofilter" :

#!/bin/sh
dir_data=/media/USER1_data/dmoyne_data/Mail_data/KDE_Mail/.Bogofilter.directory
kmail=/usr/lib/kde4/bin/kmail
#a) we train bogofilter on Spam and NonSpam folders
echo "training on Spam mail"
bogofilter -sv -B $dir_data/Spam/cur
echo "training on non-Spam mail"
bogofilter -nv -B $dir_data/NonSpam/cur
#b) we clean Spam and NonSpam folders only if KMail is not running
if [ "$(pidof $kmail)" ]
then
  echo "KMail is running : we do not delete files as this might be 
troublesome";
else
  echo "KMail is not running : we delete content of Spam and NonSpam folders";
  find $dir_data/NonSpam/cur -iname \*.* -exec rm {} \;
  find $dir_data/Spam/cur -iname \*.* -exec rm {} \;
fi
#c) we display some information on bogofilter data base
echo "message count :"
#bogoutil -w ~/.bogofilter .MSG_COUNT
echo "wordlist.db :"
#bogoutil -d ~/.bogofilter/wordlist.db
echo "finished"

Of course variables "dir_data" and "kmail" have to be set according for each 
user's setting.

You can see that in this script though training of bogofilter is all the time 
executed I preferred to delete content of "Spam" and "NonSpam" folders only if 
KMail was not running to avoid some possible conflict ; maybe such precaution 
is not needed but due to the fact that the cron action will be repeated again 
and again I found this appropriate.

So far I have tested the script that works but I will have to wait to say if 
my cron action is properly managed.
Regards.

By the way can you use KDE-4 Kmail client to send signed messages ?
Daniel.
-- 
Daniel Moyne (Nulix)---------------------------------------------------------
Distribution : Ubuntu 8.04 Hardy Heron    \\|||// Machine : x86_64
               kernel 2.6.24-19-generic   / --- \ ATI Radeon X300 Express
               KDE 3.5.9 + 4.1 (test)    (' o-o ')
----------------------------------------oOO-(_)-OOo--------------------------




More information about the Bogofilter mailing list