[Mimedefang] Spamassassin detailed score in message header

Ron Wilhoite ronw at bals.org
Wed Nov 29 11:05:55 EST 2006


On 11/29/2006 10:44 AM, Tim Boyer wrote:
>         action_change_header("X-Spam-Score", "$hits ($score) $names");
> 
> works great, and gives me the total score.  It would be great, however, if I
> could get more detail, e.g.,
> 
> X-Spam-Score: 8.152 (********) AWL,BAYES_99 (5.38),DCC_CHECK
> (2.10),DNS_FROM_RFC_ABUSE (0.32),DNS_FROM_RFC_POST (0.22),FORGED_RCVD_HELO
> (1.23),UNDISC_RECIPS (0.01)
> 
> Is there an easy way to do this?  Or could someone point me to where it's
> spelled out in excruciating detail in the docs and I missed it completely?
> 
> Thanks much,
> 

Culled from posts to this list over time - watch line wrapping:

     if ($Features{"SpamAssassin"}) {
     # Only scan messages smaller than 100kB.
     if (-s "./INPUTMSG" < 100*1024) {
         my($hits, $req, $names, $report) = spam_assassin_check();
             # add our things
             $hits += $SA_score_additions;
             $names .= $SA_test_additions;
             $report .= $SA_report_additions;
             my $fixed_report = $report;
             $fixed_report =~ s/\n+\z//g;
             $fixed_report =~ s/\n+/\n\t/g;

         if ($hits >= 20) {
             md_syslog('info', "Tagged as 
spam,$MsgID,$hits,$RelayHostname,$RelayAddr,$Sender, at Recipients,$Subject");
             return action_discard();
         }

         if ($hits >= $req) {
             my $report_length = length($fixed_report);
             md_syslog('info', "Tagged as 
spam,$MsgID,$hits,$RelayHostname,$RelayAddr,$Sender, at Recipients,$Subject");
             action_change_header("X-Spam-Score", "$hits");
             if ($report_length < 8193) {
                 action_add_header("X-Spam-Report", "$fixed_report");
             } else {
                 action_change_header("X-Spam-Score", "$hits $names");
             }
             # Add a header with original recipients, just for info
             action_add_header("X-Orig-Rcpts", join(", ", @Recipients));
             # Remove original recipients
             foreach $recip (@Recipients) {
                 delete_recipient($recip);
             }
             # Send to spamadmin instead
             add_recipient('ourspamdrop at deleted.tld');
         } else {
             action_change_header("X-Spam-Score", "$hits $names");
         }

Ron Wilhoite



More information about the MIMEDefang mailing list