Mail::SPF::Mech(3)
π¦ NAME π¦
okay so bestie, welcome to the man page for Mail::SPF::Mech β that's section 3 of the User Contributed Perl Documentation, and it's the SPF record mechanism base class. yes, base class. it's giving scaffolding, it's giving "we do the vibes, the subclasses do the work" π
πΈ VERSION πΈ
version 3.20260331 β noted, screenshotted, memorized π
π DESCRIPTION π
so, an object of class Mail::SPF::Mech represents a mechanism within an SPF record. that's the whole personality.
but here's the tea: Mail::SPF::Mech cannot be instantiated directly. nope. not happening. you have to create an instance of a concrete sub-class instead. it's abstract, it's mysterious, it's the main character who never shows up on screen π«Ά
π Constructors π
these are the constructors, bestie:
new(%options)β returnsMail::SPF::Mech
Abstract. Creates a new SPF record mechanism object.
%options is a list of key/value pairs representing any of the following options:
textβ a string denoting the unparsed text of the mechanism.qualifierβ 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'+'β¨nameβ a string denoting the name of the mechanism. required if a genericMail::SPF::Mechobject (as opposed to a specific sub-class) is being constructed. like, you can't be anonymous here, tell us your name.ip_networkβ aNetAddr::IPobject 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. no cap, do it the right way.domain_specβ either a plain string or aMail::SPF::MacroStringobject denoting an optional"domain-spec"parameter of the mechanism.ipv4_prefix_lengthipv6_prefix_length
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. yes bestie, read that twice, it's a whole trap π
other options may be specified by sub-classes of Mail::SPF::Mech.
new_from_string($text, %options)β returnsMail::SPF::Mech; throwsMail::SPF::ENothingToParse,Mail::SPF::EInvalidMech
Abstract. creates a new SPF record mechanism object by parsing the string and any options given. very "figure it out from the text" of it.
π Class methods π
the following class methods are provided, periodt:
default_qualifierβ returns string. returns the default qualifier, i.e.'+'. iconic, consistent, never changing.default_ipv4_prefix_lengthβ returns integer. returns the default IPv4 network prefix length, i.e.32.default_ipv6_prefix_lengthβ returns integer. returns the default IPv6 network prefix length, i.e.128.qualifier_patternβ returns Regexp. returns a regular expression that matches any legal mechanism qualifier, i.e.'+','-','~', or'?'.nameβ returns string. Abstract. returns the name of the mechanism.
this method is abstract and must be implemented by sub-classes of Mail::SPF::Mech. it's not optional, bestie, it's the assignment.
name_patternβ returns Regexp. returns a regular expression that matches any legal mechanism name.
π Instance methods π
and now the instance methods, the moment you've all been waiting for π
textβ returns string; throwsMail::SPF::ENoUnparsedText. returns the unparsed text of the mechanism. throws aMail::SPF::ENoUnparsedTextexception if the mechanism was created synthetically instead of being parsed, and no text was provided. so like, if you skipped the reading step, we notice πqualifierβ returns string. returns the qualifier of the mechanism. see the description of the"new"constructor's"qualifier"option. we already covered this, keep up π«Άparamsβ returns string. 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. so if you have no params, you're off the hook, you're free, you're unbothered.
stringifyβ returns string. 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 aMail::SPF::Mechobject as a string for the same effect, see"OVERLOADING". it's giving "just use the object, it knows what to do".domain($server, $request)β returns string. 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"inMail::SPF::Request) otherwise. both aMail::SPF::Serverand aMail::SPF::Requestobject are required for resolving the target domain. bring both, or don't come at all.match($server, $request)β returns boolean; throwsMail::SPF::Result::Error. Abstract. checks whether the mechanism matches the parameters of the given request (seeMail::SPF::Request) and returns true if it does, or false otherwise. in any case, takes both aMail::SPF::Serverand aMail::SPF::Requestobject.
this method is abstract and must be implemented by sub-classes of Mail::SPF::Mech. yes, again. abstract. we said what we said π
match_in_domain($server, $request)β returns boolean; throwsMail::SPF::Result::Errormatch_in_domain($server, $request, $domain)β returns boolean; throwsMail::SPF::Result::Error
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. exact algorithm, bestie, we're not improvising
this method exists mainly for the convenience of sub-classes of Mail::SPF::Mech. it's a little gift, a little treat π
explain($server, $request, $result)β 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. so don't touch it, it's handled.
explanation_template($server, $request, $result)β returns string. 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. pick a lane, both are valid πΈ
π«Ά OVERLOADING π«Ά
if a Mail::SPF::Mech object is used as a string, the "stringify" method is used to convert the object into a string. that's it, that's the whole section, it just works β¨
β SEE ALSO β
go read these too, they're all in the group chat:
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::IncludeMail::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. iykyk π
π AUTHORS π
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org>
okay that's the whole page bestie, go forth and parse mechanisms responsibly ππ¦π
perl v5.42.1 Β· 2026-04-23 Β· Mail::SPF::Mech(3) β mwah, that's a wrap π β¨
π¦ where this page comes from
- fedora 44: perl-Mail-SPF 3.20260331-1.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms