[Mimedefang] get tests including scores from SA
John Rudd
john at rudd.cc
Mon Nov 27 19:06:34 EST 2006
John Rudd wrote:
> Sven Schuster wrote:
>> Hi David,
>>
>> On Mon, Nov 27, 2006 at 04:56:55PM -0500, David F. Skoll told us:
>>> Sure. It's not written in stone that you have to use
>>> spam_assassin_check(). If you'd rather, you can call
>>> spam_assassin_status(),
>>> which returns the Mail::SpamAssassin::PerMsgStatus object. You can then
>>> manipulate that as desired.
>>
>> thanks for this really fast answer!
>> Of course you are right, I just thought something like that some
>> seconds after hitting "y" in mutt to send the mail ;-)
>> Little bit too late here in .de for doing something productive...
>>
>>
>
> I actually use the report that spam_assassin_check() returns, and sift
> out the lines that refer to tests.
...
>
> I'll post the subroutine I use for this after I make that leap. It
> literally just takes a header name variable and the $report result, from
> spam_assassin_check(), as arguments.
>
> generate_report_headers("X-SpamReport", $report);
>
>
Here's the code (I had misremembered the subroutine name, though). If
anyone has suggestions for improvements, let me know.
sub add_spam_report_headers {
my $headername = shift(@_);
my $report = shift(@_);
my (@repin, @repout, $temp);
@repin = split(/\n/, $report);
while ($repin[0] !~ /Content analysis details:/) {
shift(@repin);
}
shift(@repin);
for ($i = 0; $i <= $#repin ; $i++) {
$temp = $repin[$i];
$temp =~ s/^\s+//;
$temp =~ s/\s+$//;
if ( ($temp ne "")
&& ($temp !~ /^(\-|\s)+$/)
&& ($temp !~ /^pts\s+rule\s+name\s+description$/) ) {
action_add_header($headername, $temp);
}
}
}
More information about the MIMEDefang
mailing list