Hi Eric,
Am 21.12.2011 um 19:48 schrieb Eric Shubert:
> Here's the script I use with a shared folder to learn ham and spam, fwiw:
> #!/bin/sh
> #####################################################################
> # learn and remove spam and ham in shared folders
> #####################################################################
> # shubes 3/26/08 - created
> #####################################################################
>
> learndir="/home/vpopmail/domains/shubes.net/sa-learn"
> hambox=.Ham
> spambox=.Spam
>
> do_the_learning(){
>
> learnas=$1
> maildir=$2
>
> shopt -s extglob
> for spamfile in `find $maildir/+(cur|new)/* 2>/dev/null`; do
> sudo -u vpopmail -H sa-learn --$learnas $spamfile
> rc=$?
> if [ $? != "0" ]; then
> echo "sa-learn failed, rc=$rc, spamfile=$spamfile"
> exit $rc
> fi
> rm $spamfile
> done
> }
>
> do_the_learning ham "$learndir/$hambox"
> do_the_learning spam "$learndir/$spambox"
>
> exit 0
I am using a version of something I found on the wiki (or as part of qtp?).
It adds the following things:
- loop through all domains and users
- do not touch/learn special files (e.g. dovecot cache, etc.).
- move ham back to inbox (which is safe with dovecot - I asked the author.)
- learn items without syncing *before* making spamassassin sync the database
(if you host several domains with users actively using the ham/spam feature,
you'll be glad to do that, as perl / spam assassin is no lightweight)
# Let's define our folder conventions:
SPAMDIR=".Spam.Lernen"
HAMDIR=".Spam.Korrektur"
# find and process each SPAMDIR
for directory in $( find /home/vpopmail/domains -type d -name $SPAMDIR );
do
# then find and process each file in SPAMDIR that is not a dovecot special
file
for file in $( find $directory -type f -not \( -name dovecot.index -o -name
dovecot.index.log -o -name dovecot.index.cache -o -name dovecot-keywords -o
-name dovecot-uidlist -o -name maildirfolder \) );
do
# learn the file with sa-learn as Spam (use the vpopmail user so it ends up
in the correct database)
sudo -u vpopmail -H sa-learn --no-sync --spam ${file} >/dev/null 2>&1
# Spam belongs to nirvana!
rm -f ${file} >/dev/null 2>&1
done
done
# find and process each HAMDIR
for directory in $( find /home/vpopmail/domains -type d -name $HAMDIR );
do
# then find and process each file in HAMDIR that is not a dovecot special file
for file in $( find $directory -type f -not \( -name dovecot.index -o -name
dovecot.index.log -o -name dovecot.index.cache -o -name dovecot-keywords -o
-name dovecot-uidlist -o -name maildirfolder \) );
do
# learn the file with sa-learn as HAM (use the vpopmail user so it ends up
in the correct database)
sudo -u vpopmail -H sa-learn --no-sync --ham ${file} >/dev/null 2>&1
# move the file back to the the INBOX.
mv ${file} ${directory}/../cur >/dev/null 2>&1
done
done
# to speed up learning, we only sync the journal with the database at the end.
sudo -u vpopmail -H sa-learn --sync >/dev/null 2>&1
signature.asc
Description: Message signed with OpenPGP using GPGMail
