Showing posts with label perl spam count spamassassin. Show all posts
Showing posts with label perl spam count spamassassin. Show all posts

Saturday, April 26, 2008

Spam counter

Uses Spamassassin's determination of spam to show which email addresses have the most spam directed at them.

#!/usr/bin/perl
# cat /var/log/maillog*|./spamcount2.pl
#
# Will show which email addresses have the most spam directed at them
# based on spamassassin's decision of what is and what is not spam
#
# - nwo

while() {
if(/^.*?sendmail.*?:\s+(.*?):\s+to\=\<(.*?)\>,.*/) {
$spam{$1} = $2;
next;
}
if(/^.*?MailScanner.*?:\s+Message\s+(.*?)\s+.*?is\s+spam.*/) {
if($spam{$1}) {
$count{$spam{$1}}++;
}
}
}

foreach $line (sort(keys %count)) {
print "$line - $count{$line}\n";
}