Mail::SpamAssassin::PerMsgStatus - per-message status (spam or not-spam)
my $spamtest = new Mail::SpamAssassin ({
'rules_filename' => '/etc/spamassassin.rules',
'userprefs_filename' => $ENV{HOME}.'/.spamassassin/user_prefs'
});
my $mail = $spamtest->parse();
my $status = $spamtest->check ($mail);
if ($status->is_spam()) {
$status->rewrite_mail ();
}
...
The Mail::SpamAssassin check() method returns an object of this
class. This object encapsulates all the per-message state.
learn()The report is returned as a multi-line string, with the lines separated by
\n characters.
This is returned as a multi-line string, with the lines separated by \n
characters, containing a fully-decoded, safe, plain-text sample of the first
few lines of the message body.
get_message()The actual modifications depend on the configuration (see
Mail::SpamAssassin::Conf for more information).
The possible modifications are as follows:
X-Spam- will be added to mail depending on whether
it is spam or ham.
If report_safe is set to false (0), then the message will only have the above headers added/modified.
$status object is finished with, and can be destroyed.
If you are using SpamAssassin in a persistent environment, or checking many
mail messages from one Mail::SpamAssassin factory, this method should be
called to ensure Perl's garbage collection will clean up old status objects.
get_current_eval_rule_name()undef is
returned if no eval rule is currently being run. Useful for plugins
to determine the current rule name while inside an eval test function
call.
header_name is the name of a mail header, such as 'Subject', 'To',
etc. If default_value is given, it will be used if the requested
header_name does not exist.
Appending :raw to the header name will inhibit decoding of quoted-printable
or base-64 encoded strings.
Appending :addr to the header name will cause everything except
the first email address to be removed from the header. For example,
all of the following will result in ``example@foo'':
Appending :name to the header name will cause everything except
the first real name to be removed from the header. For example,
all of the following will result in ``Foo Blah''
There are several special pseudo-headers that can be specified:
ALL can be used to mean the text of all the message's headers.ToCc can be used to mean the contents of both the 'To' and 'Cc'
headers.EnvelopeFrom is the address used in the 'MAIL FROM:' phase of the SMTP
transaction that delivered this message, if this data has been made available
by the SMTP server.MESSAGEID is a symbol meaning all Message-Id's found in the message;
some mailing list software moves the real 'Message-Id' to 'Resent-Message-Id'
or 'X-Message-Id', then uses its own one in the 'Message-Id' header. The value
returned for this symbol is the text from all 3 headers, separated by newlines.X-Spam-Relays-Untrusted is the generated metadata of untrusted relays
the message has passed throughX-Spam-Relays-Trusted is the generated metadata of trusted relays
the message has passed throughThe returned array will include the ``raw'' URI as well as ``slightly cooked'' versions. For example, the single URI 'http://%77w%77.example.com/' will get turned into: ( 'http://%77w%77.example.com/', 'http://www.example.com/' )
clear_test_state()$status->test_log().
create_fulltext_tmpfile($fulltext) to retrieve the temporary
filename; it will be created if it has not already been.
Note: This can only be called once until $status->delete_fulltext_tmpfile() is
called.
create_fulltext_tmpfile() call. Deletes the
temporary file and uncaches the filename.
Mail::SpamAssassin
spamassassin