-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Bob Apthorpe writes:
> That should gracefully handle both SA 2.x and 3.x, correct?
actually, it looks like we totally dropped the
Mail::SpamAssassin::NoMailAudit module entirely. When we were doing
this, I suggested we leave a vestigial, empty module for that in 3.0.0 to
avoid this problem, just so that the "use" line could still be used, but
looks like I got outvoted :( So the code has to be more complex,
unfortunately.
I've also fixed a couple of buglets (use parse(), not M:SA:Message
constructor, and keep the $spamtest object around).
- --j.
At the head of the module where all the 'use' statements live...
- ----
use Mail::SpamAssassin;
use Mail::Header;
use Mail::Internet;
if ($Mail::SpamAssassin::VERSION < 3) {
eval { require Mail::SpamAssassin::NoMailAudit; };
} else {
eval { require Mail::SpamAssassin::Message; };
}
- ----
Then later, once we've wrapped the text in fake mail headers to make
a RFC822-compliant message...
- ----
# Make a M::SA object; point to custom configs
my $spamtest = Mail::SpamAssassin->new($self->{'sa_prefs'});
my $message =
Mail::Internet->new('Header' => $mailhead, 'Body' => $Rl_body);
# Fake up a mail message and stuff the comment in the body
if ($Mail::SpamAssassin::VERSION < 3) {
$self->{'_mail'} =
eval { Mail::SpamAssassin::NoMailAudit->new('data' =>
[$message->as_string]); };
} else {
$self->{'_mail'} =
eval { $spamtest->parse ([$message->as_string]); };
}
- ----
And finally, analyze the message...
- ----
# Get verdict, score, list of rules
my $status = $spamtest->check($self->{'_mail'});
- ----
- --j.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (GNU/Linux)
Comment: Exmh CVS
iD8DBQFBXDlMQTcbUG5Y7woRAiu/AKDrIzh/VRDCHZgrR8i0iXZuDxtffACdF6dU
mC7Qs3rk1L8G6/reSp3wDd0=
=5a9M
-----END PGP SIGNATURE-----