Mail::...Wrapper(3pm)

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

✨ 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 like Mail::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:

  1. a reference to the wrapper
  2. the name of the callback
  3. a subroutine reference to call into the wrapped milter
  4. the arguments for the callback (that's >= 0 of 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::Milter
  • Sendmail::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