#!/bin/sh #set -x subject="Daily Spam Summary" mailboxdir=`grep "MailboxDir" /etc/post.office.conf | cut -d "=" -f 2` junkfolder="INBOX.Junk" junkfolders=`find $mailboxdir -type d -name "$junkfolder" -print` webmailurl="http://webmail.domain.com" for i in $junkfolders do summary="" cd $i nbtotalmsg=`ls -1 | grep -v "__" | wc -l | tr -d " "` oldmsglist=`find . -type f -mtime +30 -print | grep -v "/__"` echo "$oldmsglist" nboldmsg=`echo -n "$oldmsglist" | wc -l | tr -d " "` if [ -n "$oldmsglist" ] ; then echo "$oldmsglist" | xargs rm fi newmsglist=`find . -type f -mtime 1 -print | grep -v "/__"` nbnewmsg=`echo "$newmsglist" | wc -l | tr -d " "` #echo "$newmsglist" if [ -n "$newmsglist" ] ; then for x in $newmsglist do tmp=`egrep -h "^From:|^Subject:" $x | head -2` summary="$summary ------------- $tmp" done #echo "$summary" useraccount=`dirname $i` useraccount=`basename $useraccount` #echo "$useraccount" usermail=`/usr/local/post.office/cmdutils/listacct -s ":" -i SMTP-Address $useraccount | cut -d "," -f 1` echo "$usermail" msg="This is your daily spam summary: $nbtotalmsg messages in your Junk folder. $nbnewmsg new messages in the last 24 hours. $nboldmsg old messages deleted which were older than 30 days. You can access your Junk folder through the webmail system: $webmailurl You can change your SpamFilter settings through the 'Options' menu inside the webmail interface, e.g. putting users on the white list so they won't be marked as spam or blocking users forever through the black list. The 'Learn Spam' and 'Learn FP (false positives)' folders are used to train the spam filter. When you find a spam message in your regular inbox, you can move it into the 'Learn Spam' folder so that the filter system can learn from this message and identify it in future. When you find a good message in your 'Junk' folder, you can move it to 'Learn FP' which tells the system that in future it should not classify those messages as spam. A False Positive is a message that was identified as spam but shouldn't have. Daily Summary: ============== $summary " echo "${msg}" | mail -s "${subject} - New Spam: ${nbnewmsg}" "${usermail}" fi done