The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mail::Box::Search::SpamAssassin - select spam messages with Mail::SpamAssassin

CLASS INHERITANCE

Mail::Box::Search::SpamAssassin is a Mail::Box::Search is a Mail::Reporter

SYNOPSIS

 use Mail::Box::Manager;
 my $mgr    = Mail::Box::Manager->new;
 my $folder = $mgr->open('Inbox');

 my $spam = Mail::Box::Search::SpamAssassin->new;
 if($spam->search($message)) {...}

 my @msgs   = $filter->search($folder);
 foreach my $msg ($folder->messages)
 {   $msg->delete if $msg->label('spam');
 }

 my $spam2 = Mail::Box::Search::SpamAssassin->new(deliver => 'DELETE');
 $spam2->search($folder);
 $mgr->moveMessages($folder->messages('spam'), $spamfolder);

DESCRIPTION

Spam means "unsollicited e-mail", and is as name derived from a Monty Python scatch. Although Monty Python is fun, spam is a pain: it needlessly spoils minutes of time from most people: telephone bills, overful mailboxes which block honest e-mail, and accidentally removal of honest e-mail which looks like spam. Spam is the pest of Internet.

Happily, Mail::Box can be used as spam filter, in combination with the useful Mail::SpamAssassin module (which must be installed separately). Each message which is searched is wrapped in a Mail::Message::Wrapper::SpamAssassin object.

METHODS

Initiation

assassinator

Returns the internally maintained assassinator object. You may want to reach this object for complex configuration.

new OPTIONS

Create a spam filter. Internally, a Mail::SpamAssassin object is maintained.

Only the whole message can be searched; this is a limitation of the Mail::SpamAssassin module.

 OPTION               DEFAULT
 binaries             <false>
 decode               <true>
 delayed              <true>
 deleted              <false>
 deliver              undef
 in                   'MESSAGE'
 label                'spam'
 limit                0
 log                  'WARNINGS'
 logical              'REPLACE'
 multiparts           <true>
 rewrite_mail         <true>
 sa_options           {}
 spam_assassin        undef
 trace                'WARNINGS'
binaries => BOOLEAN

See Mail::Box::Search::new(binaries)

decode => BOOLEAN

See Mail::Box::Search::new(decode)

delayed => BOOLEAN

See Mail::Box::Search::new(delayed)

deleted => BOOLEAN

See Mail::Box::Search::new(deleted)

deliver => undef|CODE|'DELETE'

See Mail::Box::Search::new(deliver)

in => 'HEAD'|'BODY'|'MESSAGE'

See Mail::Box::Search::new(in)

label => STRING|undef

Mark all selected selected message with the specified STRING. If this option is explicitly set to undef, the label will not be set.

limit => NUMBER

See Mail::Box::Search::new(limit)

log => LEVEL

See Mail::Reporter::new(log)

logical => 'REPLACE'|'AND'|'OR'|'NOT'|'AND NOT'|'OR NOT'

See Mail::Box::Search::new(logical)

multiparts => BOOLEAN

See Mail::Box::Search::new(multiparts)

rewrite_mail => BOOLEAN

Add lines to the message header describing the results of the spam scan. See Mail::SpamAssassin::PerMessageStatus::rewrite_mail().

sa_options => HASH_REF

Options to create the internal Mail::SpamAssassin object; see its manual page for the available options.

spam_assassin => OBJECT

Provide a Mail::SpamAssassin object to be used for searching spam. If none is specified, one is created internally. The object can be retreived with assassinator().

trace => LEVEL

See Mail::Reporter::new(trace)

Examples:

 my $filter = Mail::Box::Search::SpamAssassin->new
  ( in    => 'HEAD'
  , found => 'DELETE'
  );

Searching

inBody PART, BODY

See Mail::Box::Search::inBody()

inHead PART, HEAD

See Mail::Box::Search::inHead()

search FOLDER|THREAD|MESSAGE|ARRAY-OF-MESSAGES

See Mail::Box::Search::search()

searchPart PART

See Mail::Box::Search::searchPart()

The Results

printMatch [FILEHANDLE], HASH

See Mail::Box::Search::printMatch()

Logging and Tracing

defaultTrace [LEVEL, [LEVEL]

See Mail::Reporter::defaultTrace()

errors

See Mail::Reporter::errors()

log [LEVEL [,STRINGS]]

See Mail::Reporter::log()

report [LEVEL]

See Mail::Reporter::report()

reportAll [LEVEL]

See Mail::Reporter::reportAll()

trace [LEVEL]

See Mail::Reporter::trace()

warnings

See Mail::Reporter::warnings()

Other Methods

AUTOLOAD

See Mail::Reporter::AUTOLOAD()

DESTROY

See Mail::Reporter::DESTROY()

inGlobalDestruction

See Mail::Reporter::inGlobalDestruction()

logPriority LEVEL

See Mail::Reporter::logPriority()

logSettings

See Mail::Reporter::logSettings()

notImplemented

See Mail::Reporter::notImplemented()

SEE ALSO

A good start to read is Mail::Box-Overview. More documentation and a mailinglist are available from the project's website at http://perl.overmeer.net/mailbox/.

AUTHOR

Mark Overmeer (mark@overmeer.net) with the help of many.

VERSION

This code is beta, version 2.026.

Copyright (c) 2001-2002 Mark Overmeer. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.