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. π
π COPYRIGHT AND LICENSE π
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
- debian trixie: mtpolicyd 2.05-1.2 Β· GPL-2.0-only
- ubuntu questing: mtpolicyd 2.05-1.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms