By the way, I changed it a bit at the bottom to use html tables to make it a bit more 
readable. Thought I'd post what I came up with here in case anyone wanted to try it 
out. 

I'm using a little shell script as follows to save the output of the report script to 
a .html file, then emailing it to myself as an attachment using the "email" program 
from http://email.cleancode.org/. 

If anyone knows a way to send an email from the command with an html body (using Linux 
of course) I'd love to hear it, though it's not too much of a pain to open the 
attachment. I tried just saving the html file with the content-type html line at the 
top, but when piping it to /bin/mail it still showed up as a text message in my email 
client for some reason. 



--- wrapper script --- 

#!/bin/sh
/root/bin/Report_spam.pl /var/log/maillog > /root/bin/SAreport.html
email -s "SpamAssassin report" -b -q -a /root/bin/SAreport.html [EMAIL PROTECTED]



--- modification to the very bottom of the Report_spam.pl ---
--- I erased everything after line 99 and inserted this --- 

# calculate today's date real quick... format yyyy-mm-dd
my @date = reverse(localtime);
$date[3] += 1900;               # dates start at 1900
$date[4]++;                     # months start at 0 not 1
my $today = "$date[3]-$date[4]-$date[5]";

# calculate spam and ham percents...
my $ham_percent = $spamSummary{'spam.count'} * 100.0 /
  ($spamSummary{'spam.count'} + $spamSummary{'clean.count'});
my $spam_percent = $spamSummary{'clean.count'} * 100.0 /
  ($spamSummary{'spam.count'} + $spamSummary{'clean.count'});
$ham_percent = sprintf "%3.2f", $ham_percent;
$spam_percent = sprintf "%3.2f", $spam_percent;

# output the spam summary...
print "<html><body>";
print "<table border=1>";
print "<tr><td colspan=8 align=\"center\"><big><b>Spam Report (Summary) for 
$today</b><big></td></tr>";
print "<tr><td colspan=4 align=\"center\">Spam</td><td colspan=4 align=\"center\">Ham 
(non-Spam)</tr>";
print 
"<tr><td>Count</td><td>Size</td><td>Time</td><td>Percent</td><td>Count</td><td>Size</td><td>Time";
print     "</td><td>Percent</td></tr>";
print "<tr><td>$spamSummary{'spam.count'}</td><td>$spamSummary{'spam.size'}</td>";
print     
"<td>$spamSummary{'spam.time'}</td><td>$spam_percent%</td><td>$spamSummary{'clean.count'}</td>";
print     
"<td>$spamSummary{'clean.size'}</td><td>$spamSummary{'clean.time'}</td><td>$ham_percent%</td></tr>";
print "</table>";
print "<br><br>";

# output the per-user report...
print "<table border=1>";
print "<tr><td colspan=9 align=\"center\"><big><b>Spam Report (By User) for 
$today</b><big></td></tr>";
print "<tr><td>&nbsp;</td><td colspan=4 align=\"center\">Spam</td>";
print     "<td colspan=4 align=\"center\">Ham (non-Spam)</tr>";
print 
"<tr><td>Address</td><td>Count</td><td>Size</td><td>Time</td><td>Percent</td><td>Count</td>";
print     "<td>Size</td><td>Time</td><td>Percent</td></tr>";
foreach $user (sort(keys(%spamUserSummary))) {
        $spam_percent = $spamUserSummary{$user}{'spam.count'} * 100.0 /
                ($spamUserSummary{$user}{'spam.count'} + 
$spamUserSummary{$user}{'clean.count'});
        $ham_percent = $spamUserSummary{$user}{'clean.count'} * 100.0 /
                ($spamUserSummary{$user}{'spam.count'} + 
$spamUserSummary{$user}{'clean.count'});
        $ham_percent = sprintf "%3.2f", $ham_percent;
        $spam_percent = sprintf "%3.2f", $spam_percent;

        print "<tr><td>$user</td>";
        print "<td>$spamUserSummary{$user}{'spam.count'}</td>";
        print "<td>$spamUserSummary{$user}{'spam.size'}</td>";
        print "<td>$spamUserSummary{$user}{'spam.time'}</td>";
        print "<td>$spam_percent</td>";
        print "<td>$spamUserSummary{$user}{'clean.count'}</td>";
        print "<td>$spamUserSummary{$user}{'clean.size'}</td>";
        print "<td>$spamUserSummary{$user}{'clean.time'}</td>";
        print "<td>$ham_percent</td></tr>";
}
print "</table></html></body>";


-------------------------------------------------------
This SF.net email is sponsored by: IBM Linux Tutorials.
Become an expert in LINUX or just sharpen your skills.  Sign up for IBM's
Free Linux Tutorials.  Learn everything from the bash shell to sys admin.
Click now! http://ads.osdn.com/?ad_id78&alloc_id371&op=click
_______________________________________________
Spamassassin-talk mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/spamassassin-talk

Reply via email to