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($spamfolder, $folder->messages('spam'));
See SYNOPSIS in Mail::Box::Search
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.
The spam-assassin module version 2 is not really well adapted for Mail::Message objects, which will make this search even slower than spam-detection already is.
See DESCRIPTION in Mail::Box::Search