BEGIN {
for (qw(headerhas store headeris did dnsbl store_muttrc_alternates Received_for parts_linear mime_type
- body_first mimehead razor2 header_remap)) {
+ body_first mimehead spamassassin header_remap)) {
eval 'sub '.$_.' { return ::'.$_.'(@_); }';
}
}
# Do not local $store_file as it is our-imported
$store_profile="silent";
local $_;
- store "=spam".($_ eq 1 ? "" : ";$_") if $_=razor2();
+ store "=spam".($_ eq 1 ? "" : ";$_") if $_=spamassassin();
};
$store_profile=undef();
return if did sub {
# utility functions:
# return: true (error-message or "1") if is spam
-sub razor2
+sub spamassassin
{
- # razor-check has exit code 1 if NOT spam, code 0 if IS spam
+ # spamassassin has exit code 1 if IS spam, code 0 if NOT spam
local *CHILD;
- local $SIG{"PIPE"}=sub { warn "razor2 gave me SIGPIPE: broken pipe"; };
+ local $SIG{"PIPE"}=sub { warn "spamassassin gave me SIGPIPE: broken pipe"; };
# prevent Razor2's: Can't call method "log" on unblessed reference at Razor2/Client/Agent.pm line 212.
local $ENV{"HOME"}=$HOME;
- open CHILD,'|'
- .'('.'(razor-check 2>&1;echo >&3 $?)'
- .'|sed "s/^/razor-check: /"'
- .'|logger -t "perlmail['.$$.']" -p mail.crit'
- .') 3>&1'
- .'|exit `cat`'
+ open CHILD,'|spamassassin --exit-code --mbox >/dev/null'
or return 0;
print CHILD $Message;
- my $return;
- {
- local $/=undef();
- $return=<CHILD> || 1;
- }
- close CHILD;
+ my $return=close CHILD;
return undef() if !WIFEXITED($?);
return undef() if WIFSIGNALED($?);
return undef() if WIFSTOPPED($?);
- return undef() if WEXITSTATUS($?);
- return $return; # is-spam
+ return 1 if WEXITSTATUS($?); # is-spam
+ return 0; # not-spam
}
# NOTE: returns undef() if !wantarray and the first header is unrecognized