Training SpamAssassin when using Dovecot?

hkr

Verified User
Joined
Nov 6, 2006
Messages
18
Hello All,

I used to have a cronjob that trained SpamAssassin... It worked fine when my IMAP folders were actually huge files in mbox format. Then I upgraded to Dovecot...

Dovecot stores each message in separate files rather than all messages in large mbox format files. Can someone please help me how to get the training function working with this Dovecot format?
 
I am doing something ugly as: (The directory moves are because I sometimes get special directories underneath 'new', which is ehm ' interesting', together with DA we replaced a bit of code that delivers spam into /new/, now everything works fine, but I still check for it.

websrv01# cat ~remko/scripts/learnspam.sh
#!/bin/sh

HOMEDIR="/home/remko/Maildir/.INBOX.spam"
SPAMDIR="/home/remko/Maildir/.INBOX.spam/cur"
DIRLIST=`/usr/bin/find ${HOMEDIR}/cur -type d`
DIRLIST2=`/usr/bin/find ${HOMEDIR}/new -type d`

# Do an inventory for all possible directories that we need to move
# around, because they should not be there. After that learn the spam
# contents of those directories.

for DIR in ${DIRLIST}
do
if [ "${DIR}" = "/home/remko/Maildir/.INBOX.spam/cur" ]
then
/bin/echo "Current dir is cur: ${DIR}" > /dev/null 2>&1
else
/bin/echo "Something weird found under: ${DIR}"
/bin/mv ${DIR}/* /home/remko/Maildir/.INBOX.spam/new
/bin/rmdir ${DIR}
fi
done

#for DIR2 in ${DIRLIST}
#do
# if [ "${DIR2}" = "/home/remko/Maildir/.INBOX.spam/new" ]
# then
# /bin/echo "Current dir is new: ${DIR2}" > /dev/null 2>&1
# else
# /bin/echo "Something weird found under: ${DIR2}"
# /bin/mv ${DIR2}/* /home/remko/Maildir/.INBOX.spam/new
# /bin/rmdir ${DIR2}
# fi
#done
#
# Start processing files
/usr/local/bin/sa-learn --spam /home/remko/Maildir/.INBOX.spam/cur > /dev/null 2>&1
/usr/local/bin/sa-learn --spam /home/remko/Maildir/.INBOX.spam/new > /dev/null 2>&1

# Cleanout files that are no longer needed.
/bin/rm -f /home/remko/Maildir/.INBOX.spam/cur/* > /dev/null 2>&1
/bin/rm -f /home/remko/Maildir/.INBOX.spam/new/* > /dev/null 2>&1
 
Back
Top