Mail::SPF::Util(3)
π Mail::SPF::Util π
okay so bestie, this is Mail::SPF::Util β it's the little utility class that hangs out inside Mail::SPF and does all the fiddly little jobs so the main modules don't have to. it's giving "backstage crew who make the whole show work" energy, fr fr. π
β¨ VERSION β¨
this is version 3.20260331 β iconic, current, no notes. π
πΈ SYNOPSIS πΈ
here's the vibe check on how you actually call it:
use Mail::SPF::Util;
$hostname = Mail::SPF::Util->hostname;
$ipv6_address_v4mapped =
Mail::SPF::Util->ipv4_address_to_ipv6($ipv4_address);
$ipv4_address =
Mail::SPF::Util->ipv6_address_to_ipv4($ipv6_address_v4mapped);
$is_v4mapped =
Mail::SPF::Util->ipv6_address_is_ipv4_mapped($ipv6_address);
$ip_address_string = Mail::SPF::Util->ip_address_to_string($ip_address);
$reverse_name = Mail::SPF::Util->ip_address_reverse($ip_address);
$validated_domain = Mail::SPF::Util->valid_domain_for_ip_address(
$spf_server, $request,
$ip_address, $domain,
$find_best_match, # defaults to false
$accept_any_domain # defaults to false
);
$sanitized_string = Mail::SPF::Util->sanitize_string($string);
literally copy-paste and go, you're welcome. π
π¦ DESCRIPTION π¦
so Mail::SPF::Util is, and I quote, Mail::SPF's utility class. that's it, that's the whole personality β it's the friend who always has a charger, a hair tie, and a fully qualified domain name. π«Ά
π Class methods π
these are the class methods it serves up. all of them. every single one. no skipping. β¨
hostname: returns string
returns the fully qualified domain name (FQDN) of the local host. yes bestie, the whole thing, not just the cute short nickname. π
ipv4_address_to_ipv6($ipv4_address): returns NetAddr::IP; throws Mail::SPF::EInvalidOptionValue
takes the NetAddr::IP IPv4 address you hand it and converts it into an IPv4-mapped IPv6 address. and if the address you gave it is not an IPv4 address? it throws a Mail::SPF::EInvalidOptionValue exception at you. read the room, give it the right type. π
ipv6_address_to_ipv4($ipv6_address): returns NetAddr::IP; throws Mail::SPF::EInvalidOptionValue
the reverse glow-up: takes a NetAddr::IP IPv4-mapped IPv6 address and converts it back into a proper IPv4 address. if the address you pass isn't an IPv4-mapped IPv6 address, boom β Mail::SPF::EInvalidOptionValue exception. it's giving strict but fair. π
ipv6_address_is_ipv4_mapped($ipv6_address): returns boolean
returns true if the given NetAddr::IP IPv6 address is an IPv4-mapped address, and false otherwise. a simple yes/no, a vibe check in boolean form. β β
ip_address_to_string($ip_address): returns string; throws Mail::SPF::EInvalidOptionValue
hands back the given NetAddr::IP IPv4 or IPv6 address, compactly formatted as a string. for IPv4 addresses this is literally the same as calling NetAddr::IP's addr method. for IPv6 addresses it's literally the same as calling NetAddr::IP's short method. and if the object you gave it isn't a NetAddr::IP IPv4 or IPv6 address object? yep β Mail::SPF::EInvalidOptionValue exception. no cap. π₯
ip_address_reverse($ip_address): returns string; throws Mail::SPF::EInvalidOptionValue
gives you the in-addr.arpa./ip6.arpa. reverse notation of the given NetAddr::IP IPv4 or IPv6 address β you know, that backwards-looking DNS thing. and if the object isn't a NetAddr::IP IPv4 or IPv6 address object, it throws a Mail::SPF::EInvalidOptionValue exception. same energy as the one above, honestly. π
valid_domain_for_ip_address($server, $request, $ip_address, $domain, $find_best_match = false, $accept_any_domain = false): returns string or undef
okay this one's the main character of the page, pay attention. β¨
it finds a valid domain name for the given NetAddr::IP IP address that matches the given domain or a sub-domain of it. so like, what makes a domain name "valid" for an IP address? two things, and it needs both: the IP address has to reverse-map to that domain name in DNS, and then the domain name has to forward-map back to the IP address. mutual, reciprocal, both-directions slay. π
it uses the given Mail::SPF::Server and Mail::SPF::Request objects to do the DNS look-ups, and it returns the validated domain name. and if nothing works out? it returns undef. sometimes the answer is just no, bestie. π₯²
- if
$find_best_matchis true, it selects the one domain name that best matches the given domain name, and it prefers direct matches over sub-domain matches. defaults tofalse. - if
$accept_any_domainis true, any domain names are considered acceptable, even if they differ completely from the given domain name β which means the given domain name is then effectively unused, unless you requested a best match. defaults tofalse.
sanitize_string($string): returns string or undef
replaces all the non-printable or non-ascii characters in a string with their hex-escaped representation, like "\x00". it's basically a little skincare routine for your strings β strips out everything that doesn't belong. π§ββοΈπ
β SEE ALSO β
Mail::SPF
and for availability, support, and license information, go read the README file that ships with Mail::SPF. it's all in there, iykyk. π
π AUTHORS π
Julian Mehnle <julian@mehnle.net>, Shevek <cpan@anarres.org>
and that's the whole page, bestie!! this was Mail::SPF::Util(3) from the User Contributed Perl Documentation, running on perl v5.42.1, dated 2026-04-23. go forth and convert your IP addresses responsibly. mwah. π
β¨ππ¦πΈ
π¦ 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