Mail::SpamAssassin - Mail::Audit spam detector plugin
my $mail = Mail::SpamAssassin::NoMailAudit->new();
my $spamtest = Mail::SpamAssassin->new(); my $status = $spamtest->check ($mail);
if ($status->is_spam ()) { $status->rewrite_mail (); $mail->accept("spamfolder");
} else { $mail->accept(); # to default incoming mailbox } ...
Mail::SpamAssassin is a module to identify spam using text analysis and several internet-based realtime blacklists.
Using its rule base, it uses a wide range of heuristic tests on mail headers and body text to identify ``spam'', also known as unsolicited commercial email.
Once identified, the mail can then be optionally tagged as spam for later filtering using the user's own mail user-agent application.
This module also implements a Mail::Audit plugin, allowing SpamAssassin to be
used in a Mail::Audit filter. If you wish to use a command-line filter tool,
try the spamassassin
or spamd
tools provided.
Note that, if you're using Mail::Audit, the constructor for the Mail::Audit
object must use the nomime
option, like so:
my $ma = new Mail::Audit ( nomime => 1 );
SpamAssassin also includes support for reporting spam messages to collaborative filtering databases, such as Vipul's Razor ( http://razor.sourceforge.net/ ).
Mail::SpamAssassin
object. You may pass the
following attribute-value pairs to the constructor.
rules_filename
, site_rules_filename
,
and userprefs_filename
.
UNWANTED_LANGUAGE_BODY
, and are using config_text
instead of
rules_filename
, site_rules_filename
, and userprefs_filename
, you will
need to set this. It should be the path to the languages file normally
found in the SpamAssassin rules directory.
Mail::SpamAssassin::PerMsgStatus
object. Used for debugging.
username
attribute will use this as the current user's name.
Otherwise, the default is taken from the runtime environment (ie. this process'
effective UID under UNIX).
If none of rules_filename
, site_rules_filename
, userprefs_filename
, or
config_text
is set, the Mail::SpamAssassin
module will search for the
configuration files in the usual installed locations.
Mail::Audit
or
Mail::SpamAssassin::Message
object, to determine if it is spam or not.
Returns a Mail::SpamAssassin::PerMsgStatus
object which can be
used to test or manipulate the mail message.
Note that the Mail::SpamAssassin
object can be re-used for further messages
without affecting this check; in OO terminology, the Mail::SpamAssassin
object is a ``factory''. However, if you do this, be sure to call the
finish()
method on the status objects when you're done with them.
Mail::Audit
or
Mail::SpamAssassin::Message
object.
If $isspam
is set, the mail is assumed to be spam, otherwise it will
be learnt as non-spam.
If $forget
is set, the attributes of the mail will be removed from
both the non-spam and spam learning databases.
$id
is an optional message-identification string, used internally
to tag the message. If it is undef
, the Message-Id of the message
will be used. It should be unique to that message.
Returns a Mail::SpamAssassin::PerMsgLearner
object which can be used to
manipulate the learning process for each mail.
Note that the Mail::SpamAssassin
object can be re-used for further messages
without affecting this check; in OO terminology, the Mail::SpamAssassin
object is a ``factory''. However, if you do this, be sure to call the
finish()
method on the learner objects when you're done with them.
learn()
and check()
can be run using the same factory. init_learner()
must be called before using this method.
finish_learner()
) (optional, default 0).
verbose
, which will output diagnostics to stdout
if set to 1.
dump_bayes_db()
setuid
), meaning
that SpamAssassin should close any per-user databases it has open, and re-open
using ones appropriate for the new user.
Note that this should be called after reading any per-user configuration, as that data may override some paths opened in this method. You may pass the following attribute-value pairs:
username
attribute.
Otherwise identical to $f-
check()> above.
Mail::Audit
object, as human-verified spam.
This will submit the mail message to live, collaborative, spam-blocker
databases, allowing other users to block this message.
It will also submit the mail to SpamAssassin's Bayesian learner.
Options is an optional reference to a hash of options. Currently these can be:
Mail::Audit
object, as human-verified ham
(non-spam). This will revoke the mail message from live, collaborative,
spam-blocker databases, allowing other users to block this message.
It will also submit the mail to SpamAssassin's Bayesian learner as nonspam.
Options is an optional reference to a hash of options. Currently these can be:
Note that To and Cc addresses are not used.
Mail::Audit
object,
explaining that their message has been added to spam-tracking databases
and deleted. To be used in conjunction with report_as_spam
. The
$replysender
argument should contain an email address to use as the
sender of the reply message.
Note that the $mail object is not modified.
setuid()
.
DBI
module is installed, and the
configuration parameters user_scores_dsn
, user_scores_sql_username
, and
user_scores_sql_password
are set correctly.
The username in $username
will also be used for the username
attribute of
the Mail::SpamAssassin object.
Mail::SpamAssassin::PersistentAddrList
for the API these factory objects
must implement, and the API the objects they produce must implement.
Normally, Mail::SpamAssassin uses lazy evaluation where possible, but if you
plan to fork()
or start a new perl interpreter thread to process a message,
this is suboptimal, as each process/thread will have to perform these actions.
Call this function in the master thread or process to perform the actions straightaway, so that the sub-processes will not have to.
If $use_user_prefs
is 0, this will initialise the SpamAssassin
configuration without reading the per-user configuration file and it will
assume that you will call read_scoreonly_config
at a later point.
dont_copy_prefs
is
not set.
Mail::Audit
Mail::Internet
Net::DNS
See also http://spamassassin.org/ for more information.
Mail::SpamAssassin::Conf
Mail::SpamAssassin::PerMsgStatus
spamassassin
http://bugzilla.spamassassin.org/
Justin Mason <jm /at/ jmason.org>
SpamAssassin is distributed under Perl's Artistic license.
The latest version of this library is likely to be available from CPAN as well as:
http://spamassassin.org/