NAME

Mail::SPF::Server - Server class for processing SPF requests

SYNOPSIS

use Mail::SPF;

my $spf_server  = Mail::SPF::Server->new();
my $result      = $spf_server->process($request);

DESCRIPTION

Mail::SPF::Server is a server class for processing SPF requests. Each server instance can be configured with specific processing parameters and has its own result cache (TODO). Also, the default Net::DNS::Resolver DNS resolver used for making DNS look-ups can be overridden with a custom resolver object.

Constructor

The following constructor is provided:

new(%options): returns Mail::SPF::Server

Creates a new server object for processing SPF requests.

%options is a list of key/value pairs representing any of the following options:

dns_resolver

An optional DNS resolver object. If none is specified, a new Net::DNS::Resolver object is used. The resolver object may be of a different class, but it must provide an interface similar to Net::DNS::Resolver -- at least the send and errorstring methods must be supported, and the send method must return either an object of class Net::DNS::Packet, or, in the case of an error, undef.

max_dns_interactive_terms

An integer denoting the maximum number of terms (mechanisms and modifiers) per SPF record that perform DNS look-ups, as defined in RFC 4408, 10.1, paragraph 6. If undef is specified, there is no limit on the number of such terms. Defaults to 10, which is the value defined in RFC 4408.

Deviating from the default is strongly discouraged for reasons of security and predictability of SPF results!

max_name_lookups_per_term

An integer denoting the maximum number of DNS name look-ups per term (mechanism or modifier), as defined in RFC 4408, 10.1, paragraph 7. If undef is specified, there is no limit on the number of look-ups performed. Defaults to 10, which is the value defined in RFC 4408.

Deviating from the default is strongly discouraged for reasons of security and predictability of SPF results!

max_name_lookups_per_mx_mech
max_name_lookups_per_ptr_mech

An integer denoting the maximum number of DNS name look-ups per mx or ptr mechanism, respectively. Defaults to the value of the max_name_lookups_per_term option. See there for additional information and security notes.

default_explanation

A string denoting the default (not macro-expanded) explanation string. Defaults to:

'Please see http://www.openspf.org/why.html?sender=%{S}&ip=%{I}&receiver=%{R}'

Instance methods

The following instance methods are provided:

process($request): returns Mail::SPF::Result; throws Perl exceptions

Processes the given Mail::SPF::Request object, queries the authoritative domain for an SPF sender policy, evaluates the policy, and returns a Mail::SPF::Result object denoting the result of the policy evaluation.

More precisely, the following algorithm is performed:

  1. Determine the authority domain, the set of acceptable SPF record versions, and the identity scope from the given request object.

  2. Query the authority domain for SPF records of the SPF DNS RR type, discarding any records that are of an inacceptable version or do not cover the desired scope.

    If this yields no SPF records, query the authority domain for SPF records of the TXT DNS RR type, discarding any records that are of an inacceptable version or do not cover the desired scope.

    If still no acceptable SPF records could be found, processing ends with a none result.

  3. Discard all records but those of the highest acceptable version found.

    If more than one record remains, processing ends with a permerror result.

  4. Parse the selected record, constructing a Mail::SPF::Record object, and evaluate it with regard to the given identity and other request parameters. Return an appropriate result.

dns_lookup($domain, $rr_type): returns Net::DNS::Packet; throws Mail::SPF::EDNSTimeout, Mail::SPF::EDNSError

Queries the DNS using the configured resolver for resource records of the desired type at the specified domain and returns a Net::DNS::Packet object if an answer packet was received. Throws a Mail::SPF::EDNSTimeout exception if a DNS time-out occurred. Throws a Mail::SPF::EDNSError exception if an error (other than RCODE 3 AKA NXDOMAIN) occurred.

get_acceptable_records_from_packet($packet, $rr_type, \@versions, $scope, $domain): returns list of Mail::SPF::Record

Filters from the given Net::DNS::Packet object all resource records of the given RR type and for the given domain name, discarding any records that are not SPF records at all, that are of an inacceptable SPF record version, or that do not cover the given scope. Returns a list of acceptable records.

dns_resolver: returns Net::DNS::Resolver or compatible object

Returns the DNS resolver object of the server object. See the description of the "new" constructor's dns_resolver option.

max_dns_interactive_terms: returns integer
max_name_lookups_per_term: returns integer
max_name_lookups_per_mx_mech: returns integer
max_name_lookups_per_ptr_mech: returns integer

Return the limit values of the server object. See the description of the "new" constructor's corresponding options.

default_explanation: returns Mail::SPF::MacroString

Returns the default explanation as a MacroString object. See the description of the "new" constructor's default_explanation option.

SEE ALSO

Mail::SPF, Mail::SPF::Request, Mail::SPF::Result

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 421:

alternative text 'http://www.ietf.org/rfc/rfc4408.txt' contains non-escaped | or /