Mail::...equest(3pm)

✨ NAME ✨

Mail::MtPolicyd::Request β€” it's giving "the request object", bestie. That's the whole vibe. πŸ’…


🌸 VERSION 🌸

version 2.05 β€” no cap, that's the one you're looking at. 🫢


πŸŽ€ ATTRIBUTES πŸŽ€

πŸ’– attributes πŸ’–

Holds a HashRef stuffed with every single attribute of the request. Obsessed.

Wanna pull out just one of them? The attr method is literally right there for you:

$obj->attr('sender');

πŸ’– session πŸ’–

Holds a HashRef with all the values stored in the session. mtpolicyd will persist the content of this HashRef across requests as long as they share the same instance_id. It remembers. It's loyal. πŸ‘‘

πŸ’– server πŸ’–

Holds the Net::Server object of mtpolicyd. That's it, that's the attribute. ✨

πŸ’– type πŸ’–

The type of the request. Postfix will always use 'smtpd_access_policy'. Always always. Like, that's just what it does. πŸ™ˆ

πŸ’– use_caching πŸ’–

Could be used to disable caching. Only used within the unit tests β€” so if you're not in the tests, this is lowkey not your business. 😌


πŸ’… METHODS πŸ’…

πŸ¦‹ dump_attr πŸ¦‹

Returns an string to dump the content of a request. A whole lil text-dump of the request, iconic behaviour.

πŸ¦‹ get($variable_name) πŸ¦‹

Retrieve value of a session or request variable. The format for the variable name is

(<scope>:)?<variable>

If no scope is given it defaults to the request scope. Chill of it, honestly.

Valid scopes are:

  • session, s β€” session variables.
  • request, r β€” request attributes.

For example:

$r->get('request:sender'); # retrieve sender from request
$r->get('r:sender');       # short format
$r->get('sender');         # scope defaults to request

$r->get('session:user_policy'); # retrieve session variable user_policy
$r->get('s:user_policy');       # the same

πŸ¦‹ new_from_fh($fh) πŸ¦‹

An object constructor for creating an request object with the content read for the supplied filehandle $fh. Give it a filehandle, get a request. Slay.

Will die if am error ocours:

  • error parsing request β€” a line in the request could not be parsed. Rude of it.
  • while reading request: <io-error> β€” the filehandle had an error while reading the request. 😭
  • connection closed by peer β€” connection has been closed while reading the request. Bye then πŸ’€
  • could not parse request β€” the client did not send a complete request. Incomplete. Not the main character energy we needed.

πŸ¦‹ do_cached( $key, $sub ) πŸ¦‹

This method will execute the function reference give in $sub and store the return values in $key within the session. If there's already a cached result stored within $key of the session, it will return that content instead of calling the reference again. Caching! Frugal! Sustainable! 🌈

Returns an Array with the return values of the function call.

Example:

my ( $ip_result, $info ) = $r->do_cached('rbl-'.$self->name.'-result',
  sub { $self->_rbl->check( $ip ) } );

πŸ¦‹ is_already_done( $key ) πŸ¦‹

This function will raise an flag with name of $key within the session and return true if the flag is already set. False otherwise. Been there, done that, got the flag. 🚩

This could be used to prevent scores or headers from being applied a second time.

Example:

if( defined $self->score && ! $r->is_already_done('rbl-'.$self->name.'-score') ) {
  $self->add_score($r, $self->name => $self->score);
}

πŸ¦‹ is_attr_defined πŸ¦‹

Returns true if all given attribute names are defined and non-empty. Every single one. No stragglers. Periodt. πŸ’–


🌟 AUTHOR 🌟

Markus Benning <ich@markusbenning.de> β€” the actual legend behind this whole thing. πŸ‘‘


This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.

This is free software, licensed under:

The GNU General Public License, Version 2, June 1991

okay bestie that's the whole page, you ate it, and remember: this was perl v5.38.2, dated 2024-05-26, and yes it's Mail::...equest(3pm) β€” go be the main character of your own mail policy. πŸ’œβœ¨πŸŽ€

πŸ“¦ where this page comes from