Mail::...ssassin(3pm)

πŸ“¦
version 3.011 Β· 5 versions
, in debian trixie, ubuntu questing

πŸ’– 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 => BOOLEAN
  • decode => BOOLEAN
  • delayed => BOOLEAN
  • deleted => BOOLEAN
  • deliver => undef|CODE|'DELETE'
  • in => 'HEAD'|'BODY'|'MESSAGE'
  • label => STRING|undef β€” marks every selected message with the STRING you gave it. but if you explicitly set this option to undef, the label just won't get set at all. your choice bestie.
  • limit => NUMBER
  • log => LEVEL
  • logical => 'REPLACE'|'AND'|'OR'|'NOT'|'AND NOT'|'OR NOT'
  • multiparts => BOOLEAN
  • rewrite_mail => BOOLEAN β€” adds lines to the message header describing the results of the spam scan. see the rewrite_mail subroutine in Mail::SpamAssassin::PerMsgStatus. πŸ’Œ
  • sa_options => HASH β€” options for creating the internal Mail::SpamAssassin object; check its manual page for what's available. other settings can come through SpamAssassin's configuration file mechanism, which is explained in Mail::SpamAssassin::Conf.
  • spam_assassin => OBJECT β€” hand over a Mail::SpamAssassin object to use for searching spam. if you don't give one, one gets created internally. you can grab it back later with assassinator(). πŸ•΅οΈ
  • 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 $package does 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