It is quite simple if you are using MIMEDefang, I do it and have even
added a bit more information.
I think you can use the 'add_header' configuration option if you are not
using MIMEDefang. See Mail::SpamAssassin::Conf and look at the
'add_header' option it looks like it could o the job if you use the
'all' argument.
Here is how I do it in MIMEDefang:
Add you logic to filter_end. After the if($Features...
I like to see the rules and scores so I collect them in $myrpt and then
for all mail I do the action_change_header("X-Spam-Status",
&build_status_line($hits, $req, $names, $myrpt));
The build_status_line() function makes the information look more like
SA's normal report.
if ($Features{"SpamAssassin"}) {
if ((-s "./INPUTMSG") < 300*1024) {
# Only scan messages smaller than 100kB. Larger messages
# are extremely unlikely to be spam, and SpamAssassin is
# dreadfully slow on very large messages.
my($hits, $req, $names, $report) = spam_assassin_check();
# look at $report and take the n.n tag part out
my $myrpt = '';
for my $ln (split '\n', $report) {
next unless $ln =~ /^ *(\d+\.\d+) +(\w+) /;
$myrpt .= "$1:$2;";
}
# Regardless of hit or miss generate the X-Spam-Status
action_change_header("X-Spam-Status", &build_status_line($hits,
$req, $names, $myrpt));
if ($hits >= $req) {.....
This is build_status_line.
sub build_status_line {
# Still problems with the autolearn information. the code is here in
case we get it working later
my ($hits, $req, $names, $myrpt, $autolearn) = @_;
my $line;
$line = (($hits >= $req) ? "Yes, " : "No, ");
$line .= sprintf("hits=%2.1f required=%2.1f\n", $hits, $req);
if($_ = $myrpt) {
$Text::Wrap::columns = 74;
$Text::Wrap::huge = 'overflow';
$Text::Wrap::break = ';';
$line .= Text::Wrap::wrap("\ttests=", "\t ", $_) . "\n";
} else {
$line .= "\t0.0:NOTESTS\n";
}
$line .= "\tversion=" . Mail::SpamAssassin::Version();
return $line;
}
Jonn R Taylor wrote:
Hi all,
Is it possible to have X-Spam-Report added to all email headers(spam
and non-spam) and if so how.
Jonn
--
----------------
Barton L. Phillips
Applied Technology Resources, Inc.
Tel: (818)652-9850
Web: http://www.applitec.com