Mail::...Handler(3pm)
πΈ Mail::...Handler(3pm) πΈ
okay bestie, welcome to the User Contributed Perl Documentation corner of the universe, where today's main character is Mail::SpamAssassin::Handler β yes the whole thing, the (3pm) and all. sit down, hydrate, let's get into it π«Ά
β¨ NAME β¨
Mail::SpamAssassin::Handler β the superclass for MIME-part handlers. like, the parent class. the blueprint. the mother of all part-handlers π
β¨ SYNOPSIS β¨
package MyHandler;
use Mail::SpamAssassin::Handler;
our @ISA = qw(Mail::SpamAssassin::Handler);
sub new {
my ($class, $mailsaobject) = @_;
$class = ref($class) || $class;
my $self = $class->SUPER::new($mailsaobject);
bless ($self, $class);
$self->register_handler('image/jpeg', 'handle_jpeg');
return $self;
}
sub handle_jpeg {
my ($self, $node, $permsgstatus) = @_;
# ... analyse the part, optionally return synthetic child parts ...
return [];
}
that's the whole vibe right there, no cap π
β¨ DESCRIPTION β¨
so a handler is a plugin that processes individual MIME parts. it signs itself up for one or more content types using register_handler, and then it gets invoked once per matching part while the message metadata is being extracted. one part, one call. respectful. punctual. we love that for it π
Mail::SpamAssassin::Handler is a thin subclass of Mail::SpamAssassin::Plugin. handlers get loaded, configured and dispatched through exactly the same machinery as plugins do β same pipeline, same drama. but inheriting from this class instead of from Mail::SpamAssassin::Plugin gives handlers a distinct identity (so you can tell them apart with $obj->isa('Mail::SpamAssassin::Handler')) plus a place for handler-specific behaviour to live in the future. it's giving "your own locker in the hallway" energy π₯
handlers get loaded with the loadhandler / tryhandler configuration directives, and you can make a whole block of configuration conditional on a handler using ifhandler. yes. conditional config. iconic behaviour honestly β¨
everything in Mail::SpamAssassin::Plugin is available to handlers too β the whole inheritance bag, no gatekeeping. the only thing added here is the one handler-specific method below π
π¦ $handler->register_handler ($mime_pattern, $nameofsub) π¦
registers one of this handler's methods as the MIME-part handler for a content-type pattern.
$mime_patternis either an exact type (image/jpeg) or a major-type glob (image/*). and here's the rule: the most specific match wins. so no fighting in the group chat, the algorithm already decided π«Ά$nameofsubis the name of a method on this handler. it'll get called as$handler->$nameofsub($node, $permsgstatus)for every matching MIME part, during message metadata extraction β which is before body rules run and before the URI list is frozen. timing matters, bestie β°
so what can that method actually do? glad you asked:
- it can inject extracted text into the part with
$node->set_rendered($text, $type)π - it can accumulate per-message findings over on
$permsgstatusπΈ - and it can return an arrayref of synthetic child-part specs β
{ type => ..., data => $bytes, name => ... }β which get dispatched recursively π
or, if it has nothing to hand over, it returns undef or [] for none. that's it. that's the whole method. slay.
β¨ SEE ALSO β¨
Mail::SpamAssassin::Pluginβ the parent, the blueprint, the og π
okay and that's the page, bestie!! this one was written by the very mysterious and humble perl v5.40.1 on 2026-07-23, and it's signed off with every bit of Mail::...Handler(3pm) energy it deserved πβ¨ bye, go write a handler, i believe in you π
π¦ where this page comes from
- ubuntu stonking: spamassassin 4.0.2+svn1935691-1build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms