Jorge Valdes wrote to [EMAIL PROTECTED]:

Hi all,

I use mimedefang to call SpamAssassin (v2.63) to check the contents
for SPAM, and wanted to modify the X-Spam-Status header, which I
append to *all* messages that get scanned with the scores of each test
that hit. This way I could check headers to see the scores in case a
message squeeked by below my required hits threshold.

Since there is no method to do this, I implemented the following
method in PerMsgStatus.pm:

We wanted the same thing. Since I didn't want to maintain local changes to SpamAssassin code, I modified mimedefang-filter to parse the long SA report from $status->get_report(). Since mimedefang-filter is part of the local config, it won't get blown away when either SA or MD are upgraded.

$line .= $test . "=" . $self->{conf}->{scores}->{$test};

Also, your approach won't catch AWL scores, since they're scored dynamically. Add this to filter-end. Assumes you've already fetched $hits, $req, $autolearn, and $report.

        # Catch everything before the rule details
        my $ind = rindex($report, "Content analysis details:");
        my $tempreport = ($ind > -1) ? substr($report, $ind) : "";

        my $spamstatus = ($hits >= $req) ? 'Yes' : 'No';

        my ($rulestats);
        foreach my $line (split /\n/, $tempreport) {
            next unless ($line =~ /^\s*(\-?\d+\.\d+)\s+(\S+)/);
            $rulestats .= ",$2=$1";
        }
        $rulestats = substr($rulestats,1); # Remove leading comma

        my $XSpamStatus = "$spamstatus, hits=$hits required=$req "
            . "tests=$rulestats autolearn=$autolearn version="
            . $Mail::SpamAssassin::VERSION . "-"
            . $Mail::SpamAssassin::EXTRA_VERSION[0];

        # Fold the header to 72 columns on commas or spaces
        $XSpamStatus =~ s/([^\n\t]{32,64})([, ])/$1\n\t/g;

        action_change_header("X-Spam-Status", $XSpamStatus);

This, as far as I can see, exactly duplicates the behavious of the SA
X-Spam-Status header when using _TESTSSCORES(,)_.

- Ryan

--
  Ryan Thompson <[EMAIL PROTECTED]>

  SaskNow Technologies - http://www.sasknow.com
  901-1st Avenue North - Saskatoon, SK - S7K 1Y4

        Tel: 306-664-3600   Fax: 306-244-7037   Saskatoon
  Toll-Free: 877-727-5669     (877-SASKNOW)     North America

Reply via email to