Mail::...Object(3pm)
π 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()andsetpriv()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::MilterSendmail::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
- debian bookworm: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu noble: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu resolute: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- ubuntu stonking: libmail-milter-perl 0.07-2 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms