Adam M. Dunn wrote: <snip>
How cool would that be? It seems like an easy hook to implement. I would like to patch it myself for my own use, but I'm not very proficient in C. I saw someone on the net patched Courier to do the same thing so I know I'm not alone in wanting this. Anyone know how I could patch it?
Adam, Yup, that's pretty cool. You may be able to accomplish the same thing this way:
new folder learnspam
new folder learnham
- move incoming mail to folder according to spam/ham
on your *nix box setup a crontab to run every 4 hours
- 0 */4 * * * /usr/local/bin/salearn.sh
in salearn.sh, put the following
------>8------>8------>8------>8-------------- #!/bin/bash
DIR="/var/spool/mail/"
Learn() { username="$1" # the users mailbox to scan school="$2" # type of learning to do email="$3" # who to email when done
# loop through all "learn" new, cur and tmp dirs in : /var/spool/mail/$username/
for f in `find $DIR/$username -name '.learn'"$school" -type d`; do
#echo "learning spam in $f"
l1=`sa-learn --$school "$f/new/*"`
l2=`sa-learn --$school "$f/cur/*"`
l3=`sa-learn --$school "$f/tmp/*"`
NOW=`date +%D" "%T`
# creaate an email message
printf "$school learned from account %s\n---------------\nmails in new:%s\nmails in cur:%s\nmails in tmp:%s" "$username" "$l1" "$l2" "$l3" | mailx -s "$school learned for $NOW" "$email"
#echo "cleaning up learn* mail box"
# remove echo and double quotes to actually do anything
echo "/bin/rm -rf $f/new/*"
echo "/bin/rm -rf $f/cur/*"
echo "/bin/rm -rf $f/tmp/*"
done
}
# pass the account and... # the type of learning to do - also the directory name so must be either 'ham' or 'spam' # where to send the email # Learn 'testuser' 'spam' 'user1@domain.com' Learn 'testuser' 'ham' 'user1@domain.com'
------>8------>8------>8------>8--------------