SPFQUERY(1p)
๐ SPFQUERY ๐
okay bestie, listen up โ this is spfquery, it lives in the User Contributed Perl Documentation corner of your manual, and it's about to be your fave. Stay with me, it's giving very much "SPF but make it make sense." ๐ฆ
โจ NAME โจ
spfquery โ a Mail::SPF tool that checks if a given set of e-mail parameters actually matches a domain's SPF policy. Yes. That's the whole job. She's focused. ๐
๐ธ VERSION ๐ธ
version 3.20260331
๐ SYNOPSIS ๐
Preferred usage (the glow-up version, the main character):
spfquery [--versions|-v 1|2|1,2] [--scope|-s helo|mfrom|pra]
--identity|--id identity --ip-address|--ip ip-address
[--helo-identity|--helo-id helo-identity] [OPTIONS]
spfquery [--versions|-v 1|2|1,2] [--scope|-s helo|mfrom|pra]
--file|-f filename|- [OPTIONS]
Legacy usage (the old fits, still hanging around):
spfquery --helo helo-identity --ip-address|--ip ip-address [OPTIONS]
spfquery --mfrom mfrom-identity --ip-address|--ip ip-address [--helo
helo-identity] [OPTIONS]
spfquery --pra pra-identity --ip-address|--ip ip-address [OPTIONS]
Other usage (the lil side quests):
spfquery --version|-V
spfquery --help
๐ฆ DESCRIPTION ๐ฆ
So what does spfquery do, bestie? It checks if a given set of e-mail parameters (like, say, the SMTP sender's IP address) matches the responsible domain's Sender Policy Framework (SPF) policy. That's it. That's the vibe. ๐
Wanna read up on SPF itself? It's all here: <https://tools.ietf.org/html/rfc7208>
๐ Preferred Usage ๐
These forms are preferred over the legacy forms that the older spfquery versions used. Upgrade your habits, queen. ๐
The --identity form checks if the given ip-address is an authorized SMTP sender for the given helo hostname, mfrom envelope sender e-mail address, or pra (the so-called purported responsible address) e-mail address โ and which one it checks depends on the value of the --scope option, which defaults to mfrom if you just... don't say anything. No pressure. ๐
The --file form reads ip-address identity [helo-identity] tuples from the file with the specified filename โ or from standard input if filename is - โ and checks them against the specified scope (mfrom by default).
Both forms support an optional --versions option, which is a comma-separated list of the SPF version numbers of SPF records that may be used:
1meansv=spf1records should be used.2meansspf2.0records should be used.
Defaults to 1,2, i.e., it'll use any SPF records that are available. Records of a higher version get priority. Respect the hierarchy. ๐
๐ธ Legacy Usage ๐ธ
spfquery versions before 2.500 had these usage forms. They're discouraged now but still supported for backwards compatibility โ so like, they're your ex, still in your contacts, still technically functional. ๐
The --helo form checks if the given ip-address is an authorized SMTP sender for the HELO hostname given as the identity (the so-called "HELO" check).
The --mfrom form checks if the given ip-address is an authorized SMTP sender for the envelope sender email-address (or domain) given as the identity (the so-called "MAIL FROM" check). Fun lil detail: if a domain is given instead of an e-mail address, postmaster gets substituted in for the localpart. โจ
The --pra form checks if the given ip-address is an authorized SMTP sender for the PRA (Purported Responsible Address) e-mail address given as the identity.
๐ Other Usage ๐
The --version form prints version info for spfquery. The --help form prints usage info for spfquery. Short, sweet, iconic.
๐ OPTIONS ๐
๐ Standard Options ๐
Both the preferred and the legacy forms optionally take any of these OPTIONS:
--default-explanation string,--def-exp stringโ use the specified string as the default explanation if the authority domain doesn't specify an explanation string of its own. Backup queen behavior. ๐--hostname hostnameโ use hostname as the host name of the local system instead of auto-detecting it.--keep-comments,--no-keep-commentsโ do (or do not) print any comments found when reading from a file or from standard input.--sanitize(currently ignored),--no-sanitize(currently ignored) โ do (or do not) sanitize the output by condensing consecutive white-space into a single space and replacing non-printable characters with question marks. Enabled by default.--debug(currently ignored) โ print out debug information.
๐ฏ๏ธ Black Magic Options ๐ฏ๏ธ
ngl bestie, several options that earlier versions of spfquery supported are considered black magic โ i.e. potentially dangerous for the innocent user โ and are therefore disabled by default. Do not go poking around in there without knowing what you're doing. ๐ฎ
If the Mail::SPF::BlackMagic Perl module is installed (module currently not available), they may be enabled by specifying --enable-black-magic.
--max-dns-interactive-terms nโ evaluate a maximum of n DNS-interactive mechanisms and modifiers per SPF check. Defaults to10. Do not override the default unless you know what you are doing!--max-name-lookups-per-term nโ perform a maximum of n DNS name look-ups per mechanism or modifier. Defaults to10. Do not override the default unless you know what you are doing!--authorize-mxes-for email-address|domain,...โ consider all the MXes of the comma-separated list of email-addresses and domains as inherently authorized.--tfwlโ performtrusted-forwarder.orgaccreditation checking.--guess spf-termsโ use spf-terms as a default record if no SPF record is found.--local spf-termsโ process spf-terms as local policy before resorting to a default result (the implicit or explicitallmechanism at the end of the domain's SPF record). For example, this could be used for white-listing one's secondary MXes:mx:mydomain.example.org.--override domain=spf-record,--fallback domain=spf-recordโ set overrides and fallbacks. Each option can be specified multiple times. For example:
--override example.org='v=spf1 -all'
--override '*.example.net'='v=spf1 a mx -all'
--fallback example.com='v=spf1 -all'
๐ RESULT CODES ๐
passโ the specified IP address is an authorized SMTP sender for the identity. โ ate.failโ the specified IP address is not an authorized SMTP sender for the identity. โsoftfailโ the specified IP address is not an authorized SMTP sender for the identity, however the authority domain is still testing out its SPF policy. It's in its experimental era. ๐งชneutralโ the identity's authority domain makes no assertion about the status of the IP address. It's giving shrug emoji. ๐คทpermerrorโ a permanent error occurred while evaluating the authority domain's policy (e.g., a syntax error in the SPF record). Manual intervention is required from the authority domain. ๐ญtemperrorโ a temporary error occurred while evaluating the authority domain's policy (e.g., a DNS error). Try again later. โณnoneโ there is no applicable SPF policy for the identity domain. ๐
โญ EXIT CODES โญ
Result | Exit code
-----------+-----------
pass | 0
fail | 1
softfail | 2
neutral | 3
permerror | 4
temperror | 5
none | 6
๐ EXAMPLES ๐
spfquery --scope mfrom --id user@example.com --ip 1.2.3.4
spfquery --file test_data
echo "127.0.0.1 user@example.com helohost.example.com" | spfquery -f -
Look at her go. Obsessed. โจ
๐ COMPATIBILITY ๐
spfquery has undergone the following interface changes compared to earlier versions. Character development, honestly.
2.500
- A new preferred usage style for performing individual SPF checks has been introduced. The new style accepts a unified
--identityoption and an optional--scopeoption that specifies the type (scope) of the identity. In contrast, the legacy usage style requires a separate usage form for every supported scope. See "Preferred usage" and "Legacy usage" for details. ๐ - The former
unknownanderrorresult codes have been renamed topermerrorandtemperror, respectively, in order to comply with RFC 4408 terminology. Rebranded, periodt. ๐ - SPF checks with an empty identity are no longer supported. In the case of an empty "MAIL FROM" SMTP transaction parameter, perform a check with the
heloscope directly. No cap. ๐ซ - The
--debugand--(no-)sanitizeoptions are currently ignored by this version ofspfquery. They will again be supported in the future. She's on a break. ๐ด - Several features that were supported by earlier versions of
spfqueryare considered black magic and thus are now disabled by default. See "Black Magic Options". ๐ฎ - Several option names have been deprecated. This is a list of them and their preferred synonyms:
Deprecated options | Preferred options
---------------------+-----------------------------
--sender, -s | --mfrom
--ipv4, -i | --ip-address, --ip
--name | --hostname
--max-lookup-count, | --max-dns-interactive-terms
--max-lookup |
--rcpt-to, -r | --authorize-mxes-for
--trusted | --tfwl
๐ซถ SEE ALSO ๐ซถ
Mail::SPF, spfd(8)
<http://tools.ietf.org/html/rfc4408>
๐ AUTHORS ๐
This version of spfquery is a complete rewrite by Julian Mehnle <julian@mehnle.net>, based on an earlier version written by Meng Weng Wong <mengwong+spf@pobox.com> and Wayne Schlitt <wayne@schlitt.net>. Legends, all three. ๐ซก
and that's the whole page, bestie!! ๐ this gorgeous thing ships with perl v5.40.1, dated 2026-04-05, and it's part of the User Contributed Perl Documentation crew โ go forth and check those SPF policies, you absolute icon ๐ฆโจ๐
๐ฆ where this page comes from
- ubuntu stonking: spf-tools-perl 3.20260331-1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms