Mail::...Object(3pm)

πŸ“¦
version 0.07 Β· 2 versions
, in debian bookworm, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Mail::Milter::Object β€” the glow-up your milter deserves πŸ’–

okay bestie, so this is Mail::Milter::Object, a lil Perl extension living in the User Contributed Perl Documentation collection, and it's here to turn your sad little callback hashes into actual, honest-to-god objects. slay.


✨ SYNOPSIS ✨

here's the vibe, copy it exactly, don't be weird about it:

package Foo;
use base Mail::Milter::Object;

sub connect_callback {
    my $this = shift;
    my $ctx = shift;
    my @connect_args = @_;
    ...
}

...
my $milter = new Foo;

πŸ¦‹ DESCRIPTION πŸ¦‹

so, real talk: normally the milters you hand over to Sendmail::Milter are just… nondescript hash references. like, no name, no personality, just a bag of keys. πŸ’€

Mail::Milter::Object fixes that β€” it transforms those callback hashes into fully qualified objects that are way easier to maintain and actually understand. and when you pair it up with Mail::Milter::Chain, it gets even better: you get a more modular approach to milter implementation, because each milter can be its own small, granular object that exists independently of the other milters. main character energy, honestly. πŸ‘‘

every object that inherits from this class gets access to the hash reference that makes up the object itself. but bestie, two caveats, and I need you to actually read them:

  • key names you use for private data should be prefixed by an underscore (_), so nothing accidentally gets recognized as a callback name. πŸ™ˆ
  • since a milter object can be reused many times throughout its existence β€” and maybe even reentrantly if threads are in use β€” the hashref should only hold global configuration data for this object, not per-message data. anything you're storing per message or per connection? stash it in the milter context object by calling getpriv() and setpriv() on the context object. periodt. πŸ’…

πŸŽ€ METHODS πŸŽ€

new()

creates a new Mail::Milter::Object. ✨ what it does is scan the fully qualified class for milter callback methods with names of the form CALLBACK_callback. and if such a method exists? boom, a corresponding callback entry point gets added to this object. it's giving self-assembling. 🫢


πŸ‘‘ AUTHOR πŸ‘‘

Todd Vierling, <tv@duh.org> <tv@pobox.com> β€” literal icon, we stan. πŸ’œ


🌈 SEE ALSO 🌈

  • Mail::Milter
  • Sendmail::Milter

and that's the whole page, bestie!! go forth and build granular little milters. this was perl v5.36.0, dated 2023-01-22, and yes the header says Mail::...Object(3pm) because apparently we're being mysterious about it. stay iconic. πŸŽ€βœ¨πŸ’–

πŸ“¦ where this page comes from