Daily Spam report
Mike Tremaine
mgt at stellarcore.net
Sun Oct 1 16:01:08 IST 2006
> > On 30/09/06, Cornelius Koelbel <cornelius.koelbel at gmx.de> wrote:
>> >> Hi there,
>> >>
>> >> is it possible, to send a daily spam report to the user?
>> >> It is easier for my to check false positives in a list, than with every
>> >> mail.
>> >>
>> >> Besides this is a top feature for enterprise usage.
>> >> Deliver no Spams, but keep them quarantined.
>> >> Get a daily spam report and release a spam mail on user request.
>> >>
>> >> Kind regards
>> >> Cornelius
> >
> > To my knowledge you have two options:
> > 1) MailWatch (version 1.x) has a quarantine report script that will do
> > something like this. Check http://mailwatch.sf.net or the related
> > software in the MailScanner wiki.
> > 2) Fortress systems have a script that will do this (I think). Check
> > http://www.fsl.com/support/
> >
> > Having said that, I don't use either... (But there seem to be several
> > who do:-) So I can't really vouch for how well they work.
I don't have a daily spam report either but if I had to have one this is how
I'd do it.
First not sure how you store your spam I forward it to an account with this rule
Spam Actions = forward spams-store at localhost
Then I use a script to roll the IMAP Folders based on date.
#!/bin/bash
##########################################################################
#spamstore_roller.sh
#Copyright Mar 8 2005 Mike Tremaine <mgt at stellarcore.net>
#
#
##########################################################################
#
###########################
#
###########################
#Set Global dir
spamstore_user="spam-store"
spamstore_group="spamstore"
spamstore_spool="/var/spool/mail/$spamstore_user"
spamstore_maildir="/home/$spamstore_user/mail"
spamstore_mailboxlist="/home/$spamstore_user/.mailboxlist"
targetdate=$(date -d -5min +%Y%m%d)
purgeoffset=3weeks
##################
#If system has non gnu date use perl like so
#targetdate=$(perl -e 'use POSIX qw(strftime); $now_string = strftime "%Y%m%d",
localtime; print "$now_string";')
#############################
#Rotate spool to dated mbox
if [ -s $spamstore_spool ]; then
cat $spamstore_spool >> $spamstore_maildir/spam.$targetdate.mbox
cp /dev/null $spamstore_spool
chown $spamstore_user:$spamstore_user $spamstore_maildir/spam.$targetdate.mbox
fi
#############################
#Purge control
purgeday=$(date -d -$purgeoffset +%Y%m%d)
if [ -f $spamstore_maildir/spam.$purgeday.mbox ]; then
rm -f $spamstore_maildir/spam.$purgeday.mbox
fi
##############################
#Rebuild mailboxlist if needed
if [ -f $spamstore_mailboxlist ]; then
ls -1 $spamstore_maildir | sed -e 's:\(.*\)$:mail\/\1:' >
$spamstore_mailboxlist
chown $spamstore_user:$spamstore_group $spamstore_mailboxlist
fi
# vi: shiftwidth=3 tabstop=3 et
So now you have daily mailboxes for spam.... The next step to get a report
would another Perl or Bash script that could grep the To/From/Subject and make
a little list of whats in there.
Maybe this pushes you in the right direction, maybe this wastes space in your
Inbox. Good luck.
-Mike
More information about the MailScanner
mailing list