Mail::...Wrapper(3pm)
β¨ NAME β¨
Okay bestie, gather round π this is Mail::...Wrapper(3pm) β it lives in the User Contributed Perl Documentation corner of the manual-verse, and it is exactly what it says on the tin:
Mail::Milter::Wrapper β a Perl extension for wrappering milter objects π
Likeβ¦ it wraps a milter. In another milter. Milter-ception, no cap π¦
πΈ SYNOPSIS πΈ
use Mail::Milter::Wrapper;
my $milter = ...;
my $wrapper = new Mail::Milter::Wrapper($milter, \&foo);
use Sendmail::Milter;
...
Sendmail::Milter::register('foo', $wrapper, SMFI_CURR_ACTS);
That's the whole vibe. You make a wrapper, you register it, you go live π
π DESCRIPTION π
So here's the tea β β Mail::Milter::Wrapper wraps another milter, which means you get to intercept the arguments and/or the return code of the milter that's tucked inside it. It's giving "let me just peek at what you're doing before you do it" energy, and honestly? Obsessed π₯
π METHODS π
π§ new(MILTER, CODEREF[, CALLBACK ...])
Creates a Mail::Milter::Wrapper object. Iconic. Let's break down the args, because every single one matters:
MILTERβ the milter you're wrapping, bestie. It can be a plain hash reference, or an instance of a hashref object likeMail::Milter::Objectπ«ΆCODEREFβ your wrapper subroutine. The main character, literally.CALLBACK ...β optional, and they're named callbacks that the wrapper needs, even if the contained milter doesn't use them. Yes, even then. That's the whole point π
The wrapper subroutine gets called with these arguments, in exactly this order, don't shuffle them:
- a reference to the wrapper
- the name of the callback
- a subroutine reference to call into the wrapped milter
- the arguments for the callback (that's
>= 0of them, so possibly zero, possibly a whole crowd)
β οΈ MAJOR WARNING, DO NOT SKIP THIS ONE β οΈ This subroutine should ALWAYS pass the "close" callback through to the contained milter. Like, always always. If you don't, you may corrupt the contained milter's state information and cause memory leaks. Not cute. Not slay. Genuinely a bad time π So please, for me, forward the close.
π Example time
Here's a simple subroutine that just passes the callback straight through β a little "no thoughts, just forwarding" moment:
sub callback_wrapper {
shift; # don't need $this
my $cbname = shift;
my $callback_sub = shift;
&$callback_sub(@_);
}
See how it shifts off $this, grabs $cbname, grabs $callback_sub, then hands the rest of @_ right over? That's it. That's the pattern. Periodt π
β¨
π AUTHOR π
Todd Vierling, <tv@duh.org> <tv@pobox.com> β absolute legend, thank you for your service ππ
π SEE ALSO π
Mail::MilterSendmail::Milter
iykyk π
And that's the whole page, bestie β brought to you by perl v5.36.0, dated 2023-01-22, under the title Mail::...Wrapper(3pm) π¦πβ¨ Go forth and wrapper responsibly! π«ΆπΈ
π¦ 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