On Thu, 24 Apr 2014 10:50:25 -0400
"Kevin A. McGrail" <kmcgr...@pccc.com> wrote:

> I don't believe that functionality exists.  Feel free to submit a
> patch to add the option, etc. though.  Always love people submitting
> patches!

We integrate with SpamAssassin at the Perl library level, and we reach
into the innards to get at the test scores.  Here's our code:

        my $conf = $sa_status->{conf} || {};
        my $scores = $conf->{scores} || {};
        my $testnames = join(',', (map { (exists($scores->{$_}) && 
defined($scores->{$_})) ? $_ . ':' . $scores->{$_} : "$_:?" } (split(/\s*,\s*/, 
$sa_status->get_names_of_tests_hit()))));

We end up getting output like this in our logs:

HTML_IMAGE_ONLY_20:0.7;HTML_MESSAGE:0.001;MIME_HTML_ONLY:1.105;RDNS_NONE:1.274;TO_EQ_FM_DOM_HTML_ONLY:0.489;TO_EQ_FM_HTML_ONLY:0.036;TO_NO_BRKTS_NORDNS:0.001;T_REMOTE_IMAGE:0.01

Could we make an official API call something like this?

#==========================================
package Mail::SpamAssassin::PerMsgStatus;

sub get_hits_with_scores
{
        my ($self) = @_;
        my $conf = $self->{conf} || {};
        my $scores = $conf->{scores} || {};
        my $ans = {};
        foreach my $hit ($self->get_names_of_tests_hit()) {
                # Not really sure if defaulting to 0 is correct below...
                $ans->{$hit} = (exists($scores->{$hit}) && 
defined($scores->{$hit})) ? $scores->{$hit} : 0;
        }
        return $ans
}
#==========================================

which returns a hashref of testname => score

Regards,

David.

Reply via email to