Scroll to navigation

Mail::SPF::Mech(3) User Contributed Perl Documentation Mail::SPF::Mech(3)

NAME

Mail::SPF::Mech - SPF record mechanism base class

DESCRIPTION

An object of class Mail::SPF::Mech represents a mechanism within an SPF record. Mail::SPF::Mech cannot be instantiated directly. Create an instance of a concrete sub-class instead.

Constructors

The following constructors are provided:

Abstract. Creates a new SPF record mechanism object.

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

A string denoting the unparsed text of the mechanism.
A single-character string denoting the qualifier of the mechanism. Any of the following may be specified: '+' ("Pass"), '-' ("Fail"), '~' ("SoftFail"), '?' ("Neutral"). See RFC 4408, 4.6.2 and 2.5, for their meanings. Defaults to '+'.
A string denoting the name of the mechanism. Required if a generic Mail::SPF::Mech object (as opposed to a specific sub-class) is being constructed.
A NetAddr::IP object denoting an optional IP address network parameter of the mechanism. Can be either an IPv4 or an IPv6 address, with an optional network prefix length. IPv4-mapped IPv6 addresses (e.g. '::ffff:192.168.0.1') must not be specified directly, but as plain IPv4 addresses.
Either a plain string or a Mail::SPF::MacroString object denoting an optional "domain-spec" parameter of the mechanism.
A string denoting an optional IPv4 or IPv6 network prefix length for the "domain_spec" of the mechanism. Note that these options do not apply to the "ip_network" option, which already includes an optional network prefix length.

Other options may be specified by sub-classes of Mail::SPF::Mech.

Abstract. Creates a new SPF record mechanism object by parsing the string and any options given.

Class methods

The following class methods are provided:

Returns the default qualifier, i.e. '+'.
Returns the default IPv4 network prefix length, i.e. 32.
Returns the default IPv6 network prefix length, i.e. 128.
Returns a regular expression that matches any legal mechanism qualifier, i.e. '+', '-', '~', or '?'.
Abstract. Returns the name of the mechanism.

This method is abstract and must be implemented by sub-classes of Mail::SPF::Mech.

Returns a regular expression that matches any legal mechanism name.

Instance methods

The following instance methods are provided:

Returns the unparsed text of the mechanism. Throws a Mail::SPF::ENoUnparsedText exception if the mechanism was created synthetically instead of being parsed, and no text was provided.
Returns the qualifier of the mechanism. See the description of the "new" constructor's "qualifier" option.
Abstract. Returns the mechanism's parameters formatted as a string.

A sub-class of Mail::SPF::Mech does not have to implement this method if it supports no parameters.

Formats the mechanism's qualifier, name, and parameters as a string and returns it. (A qualifier that matches the default of '+' is omitted.) You can simply use a Mail::SPF::Mech object as a string for the same effect, see "OVERLOADING".
Returns the target domain of the mechanism. Depending on whether the mechanism does have an explicit "domain_spec" parameter, this is either the macro-expanded "domain_spec" parameter, or the request's authority domain (see "authority_domain" in Mail::SPF::Request) otherwise. Both a Mail::SPF::Server and a Mail::SPF::Request object are required for resolving the target domain.
Abstract. Checks whether the mechanism matches the parameters of the given request (see Mail::SPF::Request) and returns true if it does, or false otherwise. In any case, takes both a Mail::SPF::Server and a Mail::SPF::Request object.

This method is abstract and must be implemented by sub-classes of Mail::SPF::Mech.

Checks whether the mechanism's target domain name (that is, any of its DNS "A" or "AAAA" records) matches the given request's IP address (see "ip_address" in Mail::SPF::Request), and returns true if it does, or false otherwise. If an explicit domain is specified, it is used instead of the mechanism's target domain. The mechanism's IP network prefix lengths are respected when matching DNS address records against the request's IP address. See RFC 4408, 5, for the exact algorithm used.

This method exists mainly for the convenience of sub-classes of Mail::SPF::Mech.

Locally generates an explanation for why the mechanism caused the given result, and stores it in the given request object's state.

There is no need to override this method in sub-classes. See the "explanation_template" method.

Returns a macro string template for a locally generated explanation for why the mechanism caused the given result object.

Sub-classes should either define an "explanation_templates_by_result_code" hash constant with their own templates, or override this method.

OVERLOADING

If a Mail::SPF::Mech object is used as a string, the "stringify" method is used to convert the object into a string.

SEE ALSO

Mail::SPF::Mech::All, Mail::SPF::Mech::IP4, Mail::SPF::Mech::IP6, Mail::SPF::Mech::A, Mail::SPF::Mech::MX, Mail::SPF::Mech::PTR, Mail::SPF::Mech::Exists, Mail::SPF::Mech::Include

Mail::SPF, Mail::SPF::Record, Mail::SPF::Term

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

2014-05-02 perl v5.16.3