[Mimedefang] MD/SA and Outlook
Todd Aiken
taiken at ubishops.ca
Thu Jan 20 13:15:00 EST 2005
On 20 Jan 2005 at 9:23, Gary Funck wrote:
> Did you really want to put the full report into the headers, and not
> something
> a bit more abbreviated such as the more/less original rendition?
>
> action_change_header("X-Spam-Score", "$hits ($score) $names");
>
> The code that KAM/JKC contributed, is what we use:
>
> Note that we add the "report safe" attachment if it is determined
> that the mail is spam, and we add the spam score, along with the $names
> of the rules that hit, even it is determined not to be spam.
Here is what I use:
# No sense doing any extra work
return if message_rejected();
# Spam checks if SpamAssassin is installed
if ($Features{"SpamAssassin"}) {
if (-s "./INPUTMSG" < 100*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();
# Reset greylist triplet(s)?
if (defined($greylist) && $greylist && defined($gdb_reset) &&
$hits > $gdb_reset) {
if ($gdb_reset_host) {
greylist_reset($RelayAddr,"","");
} else {
foreach my $currecipient(@Recipients) {
greylist_reset($RelayAddr,$Sender,$currecipient);
md_syslog('debug', "filter_end, reset greylist
for data $Sender at $RelayAddr to $currecipient");
}
}
}
my($score);
if ($hits < 40) {
$score = "#" x int($hits);
} else {
$score = "#" x 40;
}
# We add a header which looks like this:
# X-Spam-Level: 6.8 (######) NAME_OF_TEST,NAME_OF_TEST
# The number of pound signs in parens is the integer part
# of the spam score clamped to a maximum of 40.
# MUA filters can easily be written to trigger on a
# minimum number of pound signs...
action_change_header("X-Spam-Level", "$score ($hits)");
action_change_header("X-Spam-Tests", "$names");
if ($hits >= $req) {
md_graphdefang_log('spam', $hits, $RelayAddr);
my $fixed_report = $report;
$fixed_report =~ s/\n+\z//g; # fixes for multiline
header
$fixed_report =~ s/\n/\n\t/g; # to stop sendmail
complaining
action_change_header('X-Spam-Report', $fixed_report);
# # If you find the SA report useful, add it, I guess...
# action_add_part($entity, "text/plain", "-suggest",
# "$report\n",
# "SpamAssassinReport.txt", "inline");
} else {
# Delete any existing X-Spam-Score header?
action_delete_header("X-Spam-Score");
}
}
}
As you can see, we only add the extra information to the headers if the
message is flagged as SPAM (currently if scoring >5).
CU L8R...
Todd A. Aiken
Systems Analyst - Administrator
Cole Computer Centre
BISHOP'S UNIVERSITY
Lennoxville, Quebec, CANADA
HTML in email is like putting an air conditioner on a motorcycle.
Read why here: http://www.expita.com/nomime.html
More information about the MIMEDefang
mailing list