Mail::SPF::Request(3)
π Mail::SPF::Request π
okay bestie, buckle up β this is Mail::SPF::Request(3), straight out of the User Contributed Perl Documentation section of your man pages, and it's literally the class that models an SPF request. no cap, it's lowkey iconic. π
β¨ VERSION β¨
version 3.20260331 β yes that's the real one, don't come for me π«Ά
πΈ SYNOPSIS πΈ
use Mail::SPF;
my $request = Mail::SPF::Request->new(
versions => [1, 2], # optional
scope => 'mfrom', # or 'helo', 'pra'
identity => 'fred@example.com',
ip_address => '192.168.0.1',
helo_identity # optional,
=> 'mta.example.com' # for %{h} macro expansion
);
my @versions = $request->versions;
my $scope = $request->scope;
my $authority_domain
= $request->authority_domain;
my $identity = $request->identity; # 'localpart@domain' or 'domain'
my $domain = $request->domain;
my $localpart = $request->localpart;
my $ip_address = $request->ip_address; # IPv4 or IPv6 address
my $ip_address_v6 # native IPv6 address or
= $request->ip_address_v6; # IPv4-mapped IPv6 address
my $helo_identity # additional HELO identity
= $request->helo_identity; # for non-HELO scopes
my $record = $request->record;
# the record selected during processing of the request, may be undef
$request->state(field => 'value');
my $value = $request->state('field');
π¦ DESCRIPTION π¦
So like, an object of class Mail::SPF::Request represents an SPF request. that's the whole vibe. simple. elegant. main character energy. β¨
π Constructors π
here's what you can call to make one:
new(%options): returnsMail::SPF::Requestβ makes you a brand new SPF request object. this request gets to be the root-request for any sub-requests that come after it (peep thenew_sub_requestconstructor below, she's the one that spawns them).
%options is a list of key/value pairs, and the keys you can bring to the party are any of these:
versionsβ a reference to an array of integers listing which versions of SPF records are allowed to be used for the SPF check. only the record versions that actually cover the scope you want will get used, bestie. you gotta specify at least one applicable version. if you've only got a single record version in mind, you can just hand over a plain scalar instead of an array-ref, no biggie. defaults to all the versions that cover the desired scope (more on that below); and for the default scope of'mfrom'it defaults to[1, 2].
these are the versions that are supported:
1β usev=spf1records.2β usespf2.0records.
example, since an example ate: a value of 1 (or [1]) means only v=spf1 records should be used for the SPF check. but if you also ask for a scope of 'pra'? a Mail::SPF::EInvalidScope exception gets thrown, because v=spf1 records simply do not cover the PRA scope. π
scopeβ a string denoting the authorization scope of the identity that should be checked. defaults to'mfrom'. these are the scope values that are supported:'helo'β the given identity is theHELOparameter of an SMTP transaction (RFC 2821) and should be checked against SPF records that cover theheloscope (v=spf1). see the SPFv1 specification (RFC 4408) for the formal definition of theHELOscope.'mfrom'β the given identity is theMAIL FROMparameter of an SMTP transaction (RFC 2821), and should be checked against SPF records that cover themfromscope (v=spf1andspf2.0/mfrom). see the SPFv1 specification (RFC 4408) for the formal definition of theMAIL FROMscope.
note: in the case of an emptyMAIL FROMSMTP transaction parameter (MAIL FROM:<>), the identity checked will bepostmaster@helo nameas specified in RFC 7208. so don't panic when it's blank, she's handled. π«Ά
'pra'β the given identity is thePurported Responsible Addressof an internet message (RFC 2822) and should be checked against SPF records that cover theprascope (spf2.0/pra). see the PRA specification (RFC 4407) for the formal definition of the PRA scope.
authority_domainβ a string denoting the domain name that should be queried for sender policy records. defaults to the domain of theidentityoption. ngl there's usually no need to specify theauthority_domainoption at all, she figures it out herself.identityβ required. a string denoting the sender identity whose authorization should be checked. this is a domain name for theheloscope, and an e-mail address for themfromandprascopes.
note: an empty identity should not be passed. in the case of an emptyMAIL FROMSMTP transaction parameter ("<MAIL FROM:<" >>), the identity checked will bepostmaster@helo nameas specified in RFC 7208. so like, just don't, okay? π
ip_addressβ required for checks with thehelo,mfrom, andprascopes. either a string or aNetAddr::IPobject denoting the IP address of the host claiming the identity that is being checked. can be either an IPv4 or an IPv6 address. an IPv4-mapped IPv6 address (e.g.'::ffff:192.168.0.1') is treated as an IPv4 address. πhelo_identityβ a string denoting theHELOSMTP transaction parameter in the case that the main identity is of a scope other thanhelo. this identity is then used merely for the expansion of%{h}macros during the policy evaluation of the main identity. defaults toundef, which will be expanded to'unknown'. if the main identity is of theheloscope, this option is unused β she's just sitting there, unbothered.
new_sub_request(%options): returnsMail::SPF::Requestβ must be invoked on an existing request object. creates a new sub-request object by cloning the invoked request, which is then considered the new request's super-request. any options you specify (same ones as thenewconstructor) override the parameters of the super-request. there is usually no need to specify any options besides theauthority_domainoption. it's giving "I inherited this but I'm changing one thing" π
π§ Instance methods π§
these are the instance methods you get:
root_request: returnsMail::SPF::Requestβ returns the root of the request's chain of super-requests. specifically, returns the request itself if it has no super-requests. she's her own ancestor, periodt.super_request: returnsMail::SPF::Requestβ returns the super-request of the request, orundefif there is none.versions: returns list of string β returns a list of the SPF record versions that are used for request. see the description of thenewconstructor'sversionsoption.scope: returns string β returns the scope of the request. see the description of thenewconstructor'sscopeoption.authority_domain: returns string β returns the authority domain of the request. see the description of thenewconstructor'sauthority_domainoption.identity: returns string β returns the identity of the request. see the description of thenewconstructor'sidentityoption.domain: returns string β returns the identity domain of the request. see the description of thenewconstructor'sidentityoption.localpart: returns string β returns the identity localpart of the request. see the description of thenewconstructor'sidentityoption.ip_address: returnsNetAddr::IPβ returns the IP address of the request as aNetAddr::IPobject. see the description of thenewconstructor'sip_addressoption.ip_address_v6: returnsNetAddr::IPβ like theip_addressmethod, however, an IPv4 address is returned as an IPv4-mapped IPv6 address (e.g.'::ffff:192.168.0.1') to facilitate uniform processing. so everything matches, slay πhelo_identity: returns string β returns theHELOSMTP transaction parameter of the request. see the description of thenewconstructor'shelo_identityoption.record: returnsMail::SPF::Recordβ returns the SPF record selected during the processing of the request, orundefif there is none.state($field): returns anythingstate($field, $value): returns anything β provides an interface for storing temporary state information with the request object. this is primarily meant to be used internally byMail::SPF::Serverand otherMail::SPFclasses, so like, iykyk.
if $value is specified, stores it in a state field named $field. returns the current (new) value of the state field named $field. this method may be used as an lvalue. iconic behavior honestly. β¨
β SEE ALSO β
Mail::SPF,Mail::SPF::Server- <http://tools.ietf.org/html/rfc4408>
for availability, support, and license information, see the README file included with Mail::SPF.
π AUTHORS π
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org>
and that's the whole page bestie!! π this was perl v5.42.1, dated 2026-04-23, from the User Contributed Perl Documentation set β go forth and check those SPF requests, you absolute legend ππΈπ¦
π¦ where this page comes from
- fedora 44: perl-Mail-SPF 3.20260331-1.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms