This doc will show you how to scan each users .Spam folder, teach them as spam and/or ham and then delete them within x days

First we will want to download the spamlearn.sh to a bin folder. I usually put all my scripts in ~root/bin but you
can put them anywhere you want:


# cd ~root/bin
# fetch http://freebsdrocks.net/files/spamlearn.sh
# vi spamlearn.sh

The first 2 settings SAPROG and SAFLAGS should be ok the way they are provided you're using FreeBSD.
The DOMAIN_BASE_PATH is the default path of vpopmail.
The DOMAINS setting is A list of your local domains which you would like to use this script to learn against. Make sure the
Domains are seperated by spaces!
The next three settings are if you have a catchall setup. If you do, go ahead and uncomment them and set them as you see fit.
The next three settings are if you quarantine spam. If you do, go ahead and uncomment them and set them as you see fit.
CHECK_USERS is just how you tell Bayes to train. I set this to 2 myself. I never teach my system hams.
USER_SPAM_DIRS and USER_HAM_DIRS is the default setting. Do not change unless you changed the skel setup.
DELETE_USER_SPAM and DELETE_SPAM are optional. As it is set right now, it is set to delete spams older than 30 days.
The last 2 setttings are optional. Depends on how you want the output of the script changes. I would leave them as they are
unless you are having problems.

Now to set the correct permissions and then run it:


# chmod 755 spamlearn.sh
# ./spamlearn.sh

If you are comfortable with the way it runs, Go ahead and put it into cron (man 5 crontab for more info) and you should be all set!