Mail::...rapper(3pm)
π Mail::Milter::ContextWrapper π
okay so bestie, welcome to Mail::Milter::ContextWrapper, a lil Perl extension that wrappers the milter context (yes, "wrapper" as a verb, we're doing that today π
). It lives in the Mail::...rapper(3pm) page of the User Contributed Perl Documentation, and it's about to become your new hyperfixation.
β¨ NAME β¨
Mail::Milter::ContextWrapper β a Perl extension for wrappering the milter context. literally what it says on the tin, no cap.
πΈ SYNOPSIS πΈ
use Mail::Milter::ContextWrapper;
my $oldctx = ($ctx from callback);
# in the connect_callback
$oldctx->setpriv(new Mail::Milter::ContextWrapper($ctx,
{ methodname => \&methodimpl[, ...] }));
# in all callbacks
my $newctx = $ctx->getpriv();
# in the close_callback
$oldctx->setpriv(undef);
look at that. iconic. we love a tidy lifecycle. π¦
π DESCRIPTION π
So Mail::Milter::ContextWrapper wraps the milter context with replacement methods defined by the caller. Translation bestie: you get to intercept what the context object does and then mess with it from inside a Mail::Milter::Wrapper. main character energy fr fr. π
Now, because the wrappering has to happen on every single callback (every one, no skipping, periodt), this implementation suggests you embed the wrapper inside the private data of the milter itself. And the way it stays compatible with existing milters is by giving you its own separate setpriv and getpriv methods inside the wrapper β and those do not propagate up to the embedded context object. sneaky? no. intentional. π
π METHODS π
new(CTX, { NAME => &SUB[, ...] })
Creates a Mail::Milter::ContextWrapper object. Call this from the "connect" callback and then hand it right back over to "setpriv()". π«Ά
The NAMEs are the names of the methods you wanna override inside the wrapper. Those methods get called with the wrapper as the first argument β just like a normal object method, because it is one, bestie.
getpriv()
Returns a private data item that was set by "setpriv()". Peep Sendmail::Milter if you want more lore on that. This implementation stores the datum in the wrapper, which is exactly what lets the parent context keep a reference to the wrapper itself. cute, right? πΈ
This method cannot be overridden by the user. hands off, bestie. π
get_ctx()
Returns the parent context object stored inside this wrapper. Typically used by your method overrides so they can defer back to the real method. very "i'm just gonna pass this along to the original, no drama" of you. β¨
This method cannot be overridden by the user. π
get_key(NAME)
Get a keyed data item, separate from the "getpriv" private data. It's out-of-band data storage, so you don't have to clobber the single "priv" data item that most milters use. one slot for you, one slot for your stuff. balance. π§
getpriv()
Sets a private data item to be returned by "getpriv()". See Sendmail::Milter for more information. This implementation stores the datum in the wrapper, thus allowing the parent context to store a reference to the wrapper itself.
This method cannot be overridden by the user. π (and yeah, the page really does say getpriv() twice here β we are keeping it exactly as printed, bestie. not me fixing the typo, no ma'am. π)
set_key(NAME, VALUE)
set_key(NAME => VALUE)
Set a keyed data item, separate from the "getpriv" private data. Again: out-of-band storage, so you never gotta clobber that single "priv" data item most milters are hogging. two ways to call it, both slay. π₯
π AUTHOR π
Todd Vierling, <tv@duh.org> <tv@pobox.com> β the legend who wrote all this. we stan. π
π SEE ALSO π
Mail::MilterSendmail::Milter
and that's the whole page, bestie!! π this was perl v5.36.0, dated 2023-01-22, filed under Mail::...rapper(3pm) β go forth and wrapper your contexts, ily, bye π¦π
β¨
π¦ 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