1Mail::SPF::Mech(3)    User Contributed Perl Documentation   Mail::SPF::Mech(3)
2
3
4

NAME

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

DESCRIPTION

9       An object of class Mail::SPF::Mech represents a mechanism within an SPF
10       record.  Mail::SPF::Mech cannot be instantiated directly.  Create an
11       instance of a concrete sub-class instead.
12
13   Constructors
14       The following constructors are provided:
15
16       new(%options): returns Mail::SPF::Mech
17           Abstract.  Creates a new SPF record mechanism object.
18
19           %options is a list of key/value pairs representing any of the
20           following options:
21
22           text
23               A string denoting the unparsed text of the mechanism.
24
25           qualifier
26               A single-character string denoting the qualifier of the
27               mechanism.  Any of the following may be specified: '+'
28               ("Pass"), '-' ("Fail"), '~' ("SoftFail"), '?' ("Neutral").  See
29               RFC 4408, 4.6.2 and 2.5, for their meanings.  Defaults to '+'.
30
31           name
32               A string denoting the name of the mechanism.  Required if a
33               generic Mail::SPF::Mech object (as opposed to a specific sub-
34               class) is being constructed.
35
36           ip_network
37               A NetAddr::IP object denoting an optional IP address network
38               parameter of the mechanism.  Can be either an IPv4 or an IPv6
39               address, with an optional network prefix length.  IPv4-mapped
40               IPv6 addresses (e.g. '::ffff:192.168.0.1') must not be
41               specified directly, but as plain IPv4 addresses.
42
43           domain_spec
44               Either a plain string or a Mail::SPF::MacroString object
45               denoting an optional "domain-spec" parameter of the mechanism.
46
47           ipv4_prefix_length
48           ipv6_prefix_length
49               A string denoting an optional IPv4 or IPv6 network prefix
50               length for the "domain_spec" of the mechanism.  Note that these
51               options do not apply to the "ip_network" option, which already
52               includes an optional network prefix length.
53
54           Other options may be specified by sub-classes of Mail::SPF::Mech.
55
56       new_from_string($text, %options): returns Mail::SPF::Mech; throws
57       Mail::SPF::ENothingToParse, Mail::SPF::EInvalidMech
58           Abstract.  Creates a new SPF record mechanism object by parsing the
59           string and any options given.
60
61   Class methods
62       The following class methods are provided:
63
64       default_qualifier: returns string
65           Returns the default qualifier, i.e. '+'.
66
67       default_ipv4_prefix_length: returns integer
68           Returns the default IPv4 network prefix length, i.e. 32.
69
70       default_ipv6_prefix_length: returns integer
71           Returns the default IPv6 network prefix length, i.e. 128.
72
73       qualifier_pattern: returns Regexp
74           Returns a regular expression that matches any legal mechanism
75           qualifier, i.e. '+', '-', '~', or '?'.
76
77       name: returns string
78           Abstract.  Returns the name of the mechanism.
79
80           This method is abstract and must be implemented by sub-classes of
81           Mail::SPF::Mech.
82
83       name_pattern: returns Regexp
84           Returns a regular expression that matches any legal mechanism name.
85
86   Instance methods
87       The following instance methods are provided:
88
89       text: returns string; throws Mail::SPF::ENoUnparsedText
90           Returns the unparsed text of the mechanism.  Throws a
91           Mail::SPF::ENoUnparsedText exception if the mechanism was created
92           synthetically instead of being parsed, and no text was provided.
93
94       qualifier: returns string
95           Returns the qualifier of the mechanism.  See the description of the
96           "new" constructor's "qualifier" option.
97
98       params: returns string
99           Abstract.  Returns the mechanism's parameters formatted as a
100           string.
101
102           A sub-class of Mail::SPF::Mech does not have to implement this
103           method if it supports no parameters.
104
105       stringify: returns string
106           Formats the mechanism's qualifier, name, and parameters as a string
107           and returns it.  (A qualifier that matches the default of '+' is
108           omitted.)  You can simply use a Mail::SPF::Mech object as a string
109           for the same effect, see "OVERLOADING".
110
111       domain($server, $request): returns string
112           Returns the target domain of the mechanism.  Depending on whether
113           the mechanism does have an explicit "domain_spec" parameter, this
114           is either the macro-expanded "domain_spec" parameter, or the
115           request's authority domain (see "authority_domain" in
116           Mail::SPF::Request) otherwise.  Both a Mail::SPF::Server and a
117           Mail::SPF::Request object are required for resolving the target
118           domain.
119
120       match($server, $request): returns boolean; throws
121       Mail::SPF::Result::Error
122           Abstract.  Checks whether the mechanism matches the parameters of
123           the given request (see Mail::SPF::Request) and returns true if it
124           does, or false otherwise.  In any case, takes both a
125           Mail::SPF::Server and a Mail::SPF::Request object.
126
127           This method is abstract and must be implemented by sub-classes of
128           Mail::SPF::Mech.
129
130       match_in_domain($server, $request): returns boolean; throws
131       Mail::SPF::Result::Error
132       match_in_domain($server, $request, $domain): returns boolean; throws
133       Mail::SPF::Result::Error
134           Checks whether the mechanism's target domain name (that is, any of
135           its DNS "A" or "AAAA" records) matches the given request's IP
136           address (see "ip_address" in Mail::SPF::Request), and returns true
137           if it does, or false otherwise.  If an explicit domain is
138           specified, it is used instead of the mechanism's target domain.
139           The mechanism's IP network prefix lengths are respected when
140           matching DNS address records against the request's IP address.  See
141           RFC 4408, 5, for the exact algorithm used.
142
143           This method exists mainly for the convenience of sub-classes of
144           Mail::SPF::Mech.
145
146       explain($server, $request, $result)
147           Locally generates an explanation for why the mechanism caused the
148           given result, and stores it in the given request object's state.
149
150           There is no need to override this method in sub-classes.  See the
151           "explanation_template" method.
152
153       explanation_template($server, $request, $result): returns string
154           Returns a macro string template for a locally generated explanation
155           for why the mechanism caused the given result object.
156
157           Sub-classes should either define an
158           "explanation_templates_by_result_code" hash constant with their own
159           templates, or override this method.
160

OVERLOADING

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

SEE ALSO

166       Mail::SPF::Mech::All, Mail::SPF::Mech::IP4, Mail::SPF::Mech::IP6,
167       Mail::SPF::Mech::A, Mail::SPF::Mech::MX, Mail::SPF::Mech::PTR,
168       Mail::SPF::Mech::Exists, Mail::SPF::Mech::Include
169
170       Mail::SPF, Mail::SPF::Record, Mail::SPF::Term
171
172       <http://tools.ietf.org/html/rfc4408>
173
174       For availability, support, and license information, see the README file
175       included with Mail::SPF.
176

AUTHORS

178       Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org>
179
180
181
182perl v5.34.0                      2021-07-22                Mail::SPF::Mech(3)
Impressum