| sa_teacher (version 1.11) | index /home/ewalstad/tmp/utils/sa_teacher.py |
I needed a script to automate the task of teaching Spamassassin's Bayesian
filter about user's spam and ham. This script searches the /etc/passwd file
for users with user id's between UID_MIN and UID_MAX. For each user entry it
finds, it will check within the user's home directory for an email directory
(default is "Maildir"). It will then look for a ".spam" and ".ham" directory
under the email directory. Assuming it finds the spam and ham directories, it
will run sa-learn on the cur, new and tmp subdirectories to teach Spamassassin
about the spam and ham.
** Requires Maildir format mailboxes. **
** Be sure to set the constants in the User class before running this script. **
If run from the command line, the script will instantiate a Users object and
call its trainBoth() method. This results in training Spamassassin on both
the user's spam and ham folders.
Here's an example crontab entry for running this script every Monday,
Wednesday and Friday at 5:00pm and an entry for sending a all users (all_users
is an alias to a list of users on the machine) a reminder
to move their email into appropriate folders for training:
----- start crontab entry -----
45 16 * * Mon,Wed,Fri echo "Spam training at 5:00pm today! Remember to move or copy your spam and ham to the appropriate folders." | mail -s "Spam Training Reminder" all_users
0 17 * * Mon,Wed,Fri /usr/local/sa_teacher/sa_teacher.py
----- end crontab entry -----
| Modules | ||||||
| ||||||
| Classes | ||||||||||||||||||
|
| ||||||||||||||||||
| Data | ||
| DELETE_SPAM_AFTER = 1 __version__ = '$Revision: 1.11 $' | ||