Mail::SPF::Record(3)
π Mail::SPF::Record π
okay so bestie, welcome to Mail::SPF::Record β straight outta the User Contributed Perl Documentation, and yes it's giving "I'm an abstract base class and I know it" energy. Let's get into it π
β¨ NAME β¨
Mail::SPF::Record β abstract base class for SPF records π
β¨ VERSION β¨
version 3.20260331 β¨ (fresh, no cap)
β¨ SYNOPSIS β¨
πΈ creating a record from a string
use Mail::SPF::v1::Record;
my $record = Mail::SPF::v1::Record->new_from_string("v=spf1 a mx -all");
π¦ creating a record synthetically
use Mail::SPF::v2::Record;
my $record = Mail::SPF::v2::Record->new(
scopes => ['mfrom', 'pra'],
terms => [
Mail::SPF::Mech::A->new(),
Mail::SPF::Mech::MX->new(),
Mail::SPF::Mech::All->new(qualifier => '-')
],
global_mods => [
Mail::SPF::Mod::Exp->new(domain_spec => 'spf-exp.example.com')
]
);
β¨ DESCRIPTION β¨
so Mail::SPF::Record is an abstract base class for SPF records. and here's the tea: you literally cannot instantiate it directly. it's not gonna happen, it's not the vibe. you have to make an instance of a concrete sub-class instead, okay? π«Ά
π Constructor π
the constructors we've got on deck:
new(%options): returnsMail::SPF::Recordβ makes you a brand new SPF record object β¨
%options is a list of key/value pairs, and it can be any of these cuties:
textβ a string that's the unparsed text of the record πscopesβ a reference to an array of strings, denoting the scopes that the record covers (peep the description of the"scope"option onMail::SPF::Request's"new"constructor if you need the lore)termsβ a reference to an array ofMail::SPF::Termobjects (so like,Mail::SPF::MechorMail::SPF::Mod) that make up the record. do NOT putMail::SPF::GlobalModobjects in here β those go in the"global_mods"option instead, bestie, I'm begging πglobal_modsβ a reference to an array ofMail::SPF::GlobalModobjects that are global modifiers of the record π
new_from_string($text, %options): returnsMail::SPF::Record; throwsMail::SPF::ENothingToParse,Mail::SPF::EInvalidRecordVersion,Mail::SPF::ESyntaxErrorβ makes a new SPF record object by parsing the string plus whatever options you handed it π
π§ Class methods π§
these are the class methods, iconic behavior only:
version_tag_pattern: returnsRegexpβ Abstract. returns a regular expression that matches a legal version tag. this method is abstract, so sub-classes ofMail::SPF::Recordmust implement it, no skipping πdefault_qualifier: returnsstringβ returns the default qualifier, i.e.'+'βresults_by_qualifier: returnshash of stringβ returns a reference to a hash that maps qualifiers to result codes, like this:
Qualifier | Result code
-----------+-------------
+ | pass
- | fail
~ | softfail
? | neutral
π Instance methods π
and now the instance methods, the main characters:
text: returnsstring; throwsMail::SPF::ENoUnparsedTextβ returns the unparsed text of the record. but heads up: it throws aMail::SPF::ENoUnparsedTextexception if the record was created synthetically instead of being parsed, and no text was provided πversion_tag: returnsstringβ Abstract. returns the version tag of the record. again, abstract! sub-classes ofMail::SPF::Recordmust implement it, periodt βscopes: returnslist of stringβ returns a list of the scopes the record covers. go read the description of the"new"constructor's"scopes"option for the full story πterms: returnslist of Mail::SPF::Termβ returns a list of the terms that make up the record, excluding any global modifiers (those get returned by the"global_mods"method instead). see the description of the"new"constructor's"terms"option π«global_mods: returnslist of Mail::SPF::GlobalModβ returns a list of the record's global modifiers, ordered ascending by modifier precedence. see the description of the"new"constructor's"global_mods"option πΈglobal_mod($mod_name): returnsMail::SPF::GlobalModβ returns the global modifier with the given name if it's present in the record, and returnsundefotherwise. use this one when you want one specific global modifier instead of collecting all of them like PokΓ©mon π«Άstringify: returnsstringβ returns the record's version tag and terms (global modifiers included, obviously) formatted as a string. and btw you can just use aMail::SPF::Recordobject as a string for the exact same effect β see"OVERLOADING"below πeval($server, $request): throwsMail::SPF::Resultβ evaluates the SPF record in the context of the request parameters represented by the givenMail::SPF::Requestobject. the givenMail::SPF::Serverobject is what handles the DNS look-ups π₯. it throws aMail::SPF::Resultobject matching the outcome of the evaluation β seeMail::SPF::Result. and for the exact algorithm used, go read RFC 4408, 4.6 and 4.7, iykyk π
β¨ OVERLOADING β¨
if you use a Mail::SPF::Record object as a string, the "stringify" method is what converts the object into a string. that's it, that's the whole section, slay π
β¨ SEE ALSO β¨
Mail::SPFMail::SPF::v1::RecordMail::SPF::v2::RecordMail::SPF::TermMail::SPF::MechMail::SPF::Mod<http://tools.ietf.org/html/rfc4408>π
and for availability, support, and license info, go check the README file that ships with Mail::SPF π
β¨ AUTHORS β¨
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org> π
and that's the whole page bestie!! this one came to you courtesy ofperl v5.42.1and it's dated2026-04-23β go forth and parse responsibly πβ¨π
π¦ 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