NAME
Mail::SPF::Request - SPF request class
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
$request->state(field => 'value');
my $value = $request->state('field');
DESCRIPTION
An object of class Mail::SPF::Request represents an SPF request.
Constructor
The following constructor is provided:
- new(%options): returns Mail::SPF::Request
-
Creates a new SPF request object.
%options is a list of key/value pairs representing any of the following options:
- versions
-
A reference to an array of integers listing the versions of SPF records that may be used for the SPF check. Only those record versions that cover the desired scope will actually be used. At least one applicable version must be specified. For a single record version, a simple scalar may be specified instead of an array-ref. Defaults to all versions that cover the desired scope (see below); defaults to [1, 2] for the default scope of 'mfrom'.
The following versions are supported:
Example: A value of 1 (or [1]) means that only
v=spf1records should be used for the SPF check. If at the same time a scope of 'pra' is specified, a Mail::SPF::EInvalidScope exception will be thrown asv=spf1records do not cover the PRA scope. - scope
-
A string denoting the authorization scope against which the identity should be checked. Defaults to 'mfrom'. The following scope values are supported:
- 'helo'
-
The given identity is the
HELOparameter 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 the
MAIL FROMparameter of an SMTP transaction (RFC 2821), or, in the case of an emptyMAIL FROMparameter (MAIL FROM:<>), derived from the transaction'sHELOparameter, 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. - '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
prascope (spf2.0/pra). See the PRA specification (RFC 4407) for the formal definition of the PRA scope.
-
A string denoting the domain name that should be queried for sender policy records. Defaults to the domain of the
identityoption. There is usually no need to specify theauthority_domainoption. - identity
-
Required. A string denoting the sender identity whose authorization should be checked. This is a domain name for the
heloscope, and an e-mail address for themfromandprascopes.Note: For checks against the
mfromscope, in the case of an emptyMAIL FROMSMTP transaction parameter, the caller must provide to Mail::SPF::Request theHELOtransaction parameter instead. - ip_address
-
Required for checks against the
helo,mfrom, andprascopes. 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
HELOSMTP 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 to undef, which will be expanded to 'unknown'. If the main identity is of theheloscope, this option is unused.
Instance methods
The following instance methods are provided:
- 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
versionsoption. - scope: returns string
-
Returns the scope of the request. See the description of the "new" constructor's
scopeoption. -
Returns the authority domain of the request. See the description of the "new" constructor's
authority_domainoption. - identity: returns string
-
Returns the identity of the request. See the description of the "new" constructor's
identityoption. - domain: returns string
-
Returns the identity domain of the request. See the description of the "new" constructor's
identityoption. - localpart: returns string
-
Returns the identity localpart of the request. See the description of the "new" constructor's
identityoption. - 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_addressoption. - ip_address_v6: returns NetAddr::IP
-
Like the
ip_addressmethod, however, an IPv4 address is returned as an IPv4-mapped IPv6 address (e.g. '::ffff:192.168.0.1') to facilitate uniform processing. - helo_identity: returns string
-
Returns the
HELOSMTP transaction parameter of the request. See the description of the "new" constructor'shelo_identityoption. - 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.
If
$valueis specified, stores it in a state field named$field. Returns the current (new) value of the state field named$field.
SEE ALSO
http://www.ietf.org/rfc/rfc4408.txt
For availability, support, and license information, see the README file included with Mail::SPF.
AUTHORS
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org>
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 409:
alternative text 'http://www.ietf.org/rfc/rfc4408.txt' contains non-escaped | or /