[Spambayes] train on demand

bill parducci bill at parducci.net
Sat Mar 1 11:51:15 EST 2003


not wanting to leave mail laying around for a day whilst i wait for the daily mboxtrain.py cron job to fire off i came up with the following scheme for being able to initiate retraining via e-mail:

1. modification for .procmailrc, inserting this above the recipe that initiates hammiefilter.py:


:0
* ^Subject:.*mboxtrain.[MyKeyCode]
{
:0
* ^From.*[MyEmailAddress]
|${HOME}/retrain.sh
}


2. spiff up the shell script (retrain.sh) that calls mboxtrain.py to to send back a note telling me that the retraining is done and to output the information to a log file that can be read later ( would have included it in the note, but the way that mboxtrain.py outputs the message counts it makes for a very unwieldy message).

#!/bin/sh

mailhome="${HOME}/mail"
user=`basename ${HOME}`
inbox="/var/spool/mail/$user"
xhost=`hostname`
xdomain=`dnsdomainname`

/opt/spambayes/mboxtrain.py -d /home/$user/.hammiedb -s $mailhome/spam -g $inbox -g $mailhome/foo -g $mailhome/bar -g $mailhome/blah -g $mailhome/oink >${HOME}/retrain.out

/usr/sbin/sendmail -f devnull@$xhost.$xdomain $user <<EOF
Subject: Mailbox Training Acknowledgment

Mailbox retraining for $user has completed.

EOF


NOTE: the extra ham folders are those that are auto-filed by procmail (mailing lists that i lurk on) that are processed after hammiefilter.py is invoked.


so far, i am happy with the results (other than not being to capture usable output from hammiefilter.py in the ack e-mail). when i sit down at my machine i quickly take stock of any misplaced spam/ham, rectify the situation and fire off my training note. a minute or so later i get the ack and i then read/delete/file my mail to my heart's content.

anyway, i figure i would throw this out there in case anyone else wanted to give it a shot.

b

p.s. as a side note, i think that being able to designate a config file from the command line would be helpful in running hammiefilter.py.




More information about the Spambayes mailing list