Mail::...ssassin(3pm)
π Mail::Box::Search::SpamAssassin π
okay bestie, we're looking at Mail::...ssassin, from the User Contributed Perl Documentation pile. it's a whole module for yeeting spam out of your mailboxes and honestly? iconic. let's get into it π«Ά
β¨ NAME β¨
Mail::Box::Search::SpamAssassin β the one that selects spam messages with Mail::SpamAssassin. periodt.
π¦ INHERITANCE π¦
the family tree goes like this, no cap:
Mail::Box::Search::SpamAssassin
is a Mail::Box::Search
is a Mail::Reporter
so it inherited all the good genes π
πΈ SYNOPSIS πΈ
here's the vibe, verbatim, don't touch:
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'));
like, look at that last bit. it just moves the spam out and into a spam folder. main character energy fr fr π§
π DESCRIPTION π
so, spam. it means "unsollicited e-mail", and the name comes from a Monty Python scatch. and yeah, Monty Python is fun, but spam is genuinely a pain: it needlessly spoils minutes of time from most people β telephone bills, overful mailboxes that block honest e-mail, and accidental removal of honest e-mail that just looks like spam. spam is the pest of Internet, bestie. π
but the good news? Mail::Box can be your spam filter, when you pair it with the very useful Mail::SpamAssassin module (which you have to install separately, it doesn't come in the box). every single message that gets searched gets wrapped in a Mail::Message::Wrapper::SpamAssassin object. cute lil wrapper. π
heads up though: the spam-assassin module version 2 is not really well adapted for Mail::Message objects, which makes this search even slower than spam-detection already is. it's giving slow. π
this one extends "DESCRIPTION" in Mail::Box::Search.
π METHODS π
extends "METHODS" in Mail::Box::Search.
π Constructors π
extends "Constructors" in Mail::Box::Search.
Mail::Box::Search::SpamAssassin->new(%options)
creates a spam filter. internally it keeps a whole Mail::SpamAssassin object alive and thriving.
only the whole message can be searched β that's a limitation of the Mail::SpamAssassin module, not us, we're just the messenger. π
here's the full option table, every single row, no skipping:
-Option --Defined in --Default
binaries Mail::Box::Search <false>
decode Mail::Box::Search <true>
delayed Mail::Box::Search <true>
deleted Mail::Box::Search <false>
deliver Mail::Box::Search undef
in Mail::Box::Search 'MESSAGE'
label c<'spam'>
limit Mail::Box::Search 0
log Mail::Reporter 'WARNINGS'
logical Mail::Box::Search 'REPLACE'
multiparts Mail::Box::Search <true>
rewrite_mail <true>
sa_options { }
spam_assassin undef
trace Mail::Reporter 'WARNINGS'
and now the breakdown, one by one:
binaries => BOOLEANdecode => BOOLEANdelayed => BOOLEANdeleted => BOOLEANdeliver => undef|CODE|'DELETE'in => 'HEAD'|'BODY'|'MESSAGE'label => STRING|undefβ marks every selected message with theSTRINGyou gave it. but if you explicitly set this option toundef, the label just won't get set at all. your choice bestie.limit => NUMBERlog => LEVELlogical => 'REPLACE'|'AND'|'OR'|'NOT'|'AND NOT'|'OR NOT'multiparts => BOOLEANrewrite_mail => BOOLEANβ adds lines to the message header describing the results of the spam scan. see therewrite_mailsubroutine inMail::SpamAssassin::PerMsgStatus. πsa_options => HASHβ options for creating the internalMail::SpamAssassinobject; check its manual page for what's available. other settings can come through SpamAssassin's configuration file mechanism, which is explained inMail::SpamAssassin::Conf.spam_assassin => OBJECTβ hand over aMail::SpamAssassinobject to use for searching spam. if you don't give one, one gets created internally. you can grab it back later withassassinator(). π΅οΈtrace => LEVEL
and an example, because examples slay:
my $filter = Mail::Box::Search::SpamAssassin
->new( found => 'DELETE' );
π₯ Searching π₯
extends "Searching" in Mail::Box::Search.
$obj->assassinator()β returns the internally maintained assassinator object. you'll want to reach for it when you need complex configuration. it's the whole plug. π$obj->inBody($part, $body)β inherited, see"Searching" in Mail::Box::Search$obj->inHead($part, $head)β inherited, see"Searching" in Mail::Box::Search$obj->search($folder|$thread|$message|ARRAY)β inherited, see"Searching" in Mail::Box::Search$obj->searchPart($part)β inherited, see"Searching" in Mail::Box::Search
π The Results π
extends "The Results" in Mail::Box::Search.
$obj->printMatch( [$fh], HASH )β inherited, see"The Results" in Mail::Box::Search
π Error handling π
extends "Error handling" in Mail::Box::Search.
$obj->AUTOLOAD()β inherited, see"Error handling" in Mail::Reporter$obj->addReport($object)β inherited, see"Error handling" in Mail::Reporter$obj->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )/Mail::Box::Search::SpamAssassin->defaultTrace( [$level]|[$loglevel, $tracelevel]|[$level, $callback] )β inherited, see"Error handling" in Mail::Reporter$obj->errors()β inherited, see"Error handling" in Mail::Reporter$obj->log( [$level, [$strings]] )/Mail::Box::Search::SpamAssassin->log( [$level, [$strings]] )β inherited, see"Error handling" in Mail::Reporter$obj->logPriority($level)/Mail::Box::Search::SpamAssassin->logPriority($level)β inherited, see"Error handling" in Mail::Reporter$obj->logSettings()β inherited, see"Error handling" in Mail::Reporter$obj->notImplemented()β inherited, see"Error handling" in Mail::Reporter$obj->report( [$level] )β inherited, see"Error handling" in Mail::Reporter$obj->reportAll( [$level] )β inherited, see"Error handling" in Mail::Reporter$obj->trace( [$level] )β inherited, see"Error handling" in Mail::Reporter$obj->warnings()β inherited, see"Error handling" in Mail::Reporter
π§Ή Cleanup π§Ή
extends "Cleanup" in Mail::Box::Search.
$obj->DESTROY()β inherited, see"Cleanup" in Mail::Reporter
π DIAGNOSTICS π
- Error: Package
$packagedoes not implement$method.
fatal error bestie. the specific package (or one of its superclasses) does not implement this method where it should. what this message actually means is that some other related classes do implement this method, but the class in your hands does not. so probably you should investigate it, and probably inform the author of the package. π«Ά
π SEE ALSO π
this module is part of the Mail-Box distribution, version 3.011, built on April 18, 2025. website: http://perl.overmeer.net/CPAN/ π
β LICENSE β
copyrights 2001-2025 by [Mark Overmeer]. for other contributors see the ChangeLog. π«‘
this program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. see http://dev.perl.org/licenses/
okay and the lil footer at the bottom of the page said perl v5.40.1, dated 2025-04-25, on Mail::...ssassin(3pm) β so yeah, that's the version, the date, and the page, all wrapped up with a bow. slay, go filter some spam, ily πβ¨ππ¦πΈπ
π«Ά
π¦ where this page comes from
- debian trixie: libmail-box-perl 3.011-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libmail-box-perl 3.011-1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms