#!/bin/sh # 09/11/09 - shubes # changed -ctime to -mtime so archived files expire properly # refactored a bit to simplify # 12/12/08 - shubes # fixed bug with large number of domains/users # 09/02/08 - shubes # changed final sa-learn to suppress output so hourly emails aren't generated # 06/06/08 - shubes # fixed final sa-learn to run as vpopmail instead of root # 04/09/08 - Jake # Changed the default time from 5 to 15 to better accomidate the users who have # contacted me. # 01/02/08 - Jake # Fixed script to sudo to vpopmail before learning spam # 09/17/07 - Jake # The script was changed to no longer sync (the default) # until the script was all done, where it will then run a sync. # 06/27/07 - Jake # This script when installed as an hourly cron will look for spam messages # in a user's Spam folder (see wiki.qmailtoaster.com for --define 'spambox 1') # and automatically sa-learn from them, and then remove them # if they are more than 5 days old. # The 5-day old option can be defined/changed below. # Portions of this script came from # Erik Espinoza's pruning script # Varibale to define how old messages must be before being learned and deleted TOO_OLD=15 # find and process each .Spam directory # then find and process each file in the .Spam directory for directory in $(find /home/vpopmail/domains -type d -name .Spam); do for file in $(find $directory -type f -mtime +$TOO_OLD) ; do sudo -u vpopmail -H sa-learn --no-sync --spam ${file} >/dev/null 2>&1 rm -f ${file} >/dev/null 2>&1 done done sudo -u vpopmail -H sa-learn --sync >/dev/null 2>&1 exit 0