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): returns Mail::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 the new_sub_request constructor 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 β€” use v=spf1 records.
  • 2 β€” use spf2.0 records.

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 the HELO parameter of an SMTP transaction (RFC 2821) and should be checked against SPF records that cover the helo scope (v=spf1). see the SPFv1 specification (RFC 4408) for the formal definition of the HELO scope.
    • 'mfrom' β€” the given identity is the MAIL FROM parameter of an SMTP transaction (RFC 2821), and should be checked against SPF records that cover the mfrom scope (v=spf1 and spf2.0/mfrom). see the SPFv1 specification (RFC 4408) for the formal definition of the MAIL FROM scope.
note: in the case of an empty MAIL FROM SMTP transaction parameter (MAIL FROM:<>), the identity checked will be postmaster@helo name as specified in RFC 7208. so don't panic when it's blank, she's handled. 🫢
  • 'pra' β€” the given identity is the Purported Responsible Address of an internet message (RFC 2822) and should be checked against SPF records that cover the pra scope (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 the identity option. ngl there's usually no need to specify the authority_domain option 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 the helo scope, and an e-mail address for the mfrom and pra scopes.
note: an empty identity should not be passed. in the case of an empty MAIL FROM SMTP transaction parameter ("<MAIL FROM:<" >>), the identity checked will be postmaster@helo name as specified in RFC 7208. so like, just don't, okay? πŸ™ˆ
  • ip_address β€” required for checks with the helo, mfrom, and pra scopes. either a string or a NetAddr::IP object 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 the HELO SMTP transaction parameter in the case that the main identity is of a scope other than helo. this identity is then used merely for the expansion of %{h} macros during the policy evaluation of the main identity. defaults to undef, which will be expanded to 'unknown'. if the main identity is of the helo scope, this option is unused β€” she's just sitting there, unbothered.
  • new_sub_request(%options): returns Mail::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 the new constructor) override the parameters of the super-request. there is usually no need to specify any options besides the authority_domain option. it's giving "I inherited this but I'm changing one thing" πŸ’…

🧚 Instance methods 🧚

these are the instance methods you get:

  • root_request: returns Mail::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: returns Mail::SPF::Request β€” returns the super-request of the request, or undef if 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 the new constructor's versions option.
  • scope: returns string β€” returns the scope of the request. see the description of the new constructor's scope option.
  • authority_domain: returns string β€” returns the authority domain of the request. see the description of the new constructor's authority_domain option.
  • identity: returns string β€” returns the identity of the request. see the description of the new constructor's identity option.
  • domain: returns string β€” returns the identity domain of the request. see the description of the new constructor's identity option.
  • localpart: returns string β€” returns the identity localpart of the request. see the description of the new constructor's identity option.
  • ip_address: returns NetAddr::IP β€” returns the IP address of the request as a NetAddr::IP object. see the description of the new constructor's ip_address option.
  • ip_address_v6: returns NetAddr::IP β€” like the ip_address method, 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 the HELO SMTP transaction parameter of the request. see the description of the new constructor's helo_identity option.
  • record: returns Mail::SPF::Record β€” returns the SPF record selected during the processing of the request, or undef if there is none.
  • state($field): returns anything
  • state($field, $value): returns anything β€” provides an interface for storing temporary state information with the request object. this is primarily meant to be used internally by Mail::SPF::Server and other Mail::SPF classes, 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 ⭐

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