SPFQUERY(1)
๐ NAME ๐
okay bestie, meet spfquery(1) โ she's a User Contributed Perl Documentation girlie, and this whole page is about Mail::SPF's spfquery: the tool that checks if a given set of e-mail parameters matches a domain's SPF policy. No cap, that's the vibe. โจ
๐ธ VERSION ๐ธ
version 3.20260331 ๐
๐ฆ SYNOPSIS ๐ฆ
Preferred usage:
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:
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:
spfquery --version|-V
spfquery --help
โจ DESCRIPTION โจ
spfquery checks if a given set of e-mail parameters (e.g. the SMTP sender's IP address) matches the responsible domain's Sender Policy Framework (SPF) policy. For more information on SPF see <https://tools.ietf.org/html/rfc7208>. literally iconic behavior ๐
๐ Preferred Usage ๐
The following usage forms are preferred over the legacy forms used by older spfquery versions:
- The
--identityform checks if the given ip-address is an authorized SMTP sender for the given"helo"hostname,"mfrom"envelope sender e-mail address, or"pra"(so-called purported resonsible address) e-mail address, depending on the value of the--scopeoption (which defaults tomfromif omitted). - The
--fileform 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 (mfromby default).
Both forms support an optional --versions option, which specifies a comma-separated list of the SPF version numbers of SPF records that may be used. 1 means that "v=spf1" records should be used. 2 means that "spf2.0" records should be used. Defaults to 1,2, i.e., uses any SPF records that are available. Records of a higher version are preferred. ๐
๐ฆ Legacy Usage ๐ฆ
spfquery versions before 2.500 featured the following usage forms, which are discouraged but still supported for backwards compatibility:
- The
--heloform checks if the given ip-address is an authorized SMTP sender for the"HELO"hostname given as the identity (so-called"HELO"check). - The
--mfromform checks if the given ip-address is an authorized SMTP sender for the envelope sender email-address (or domain) given as the identity (so-called"MAIL FROM"check). If a domain is given instead of an e-mail address,"postmaster"will be substituted for the localpart. - The
--praform 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 information of spfquery. The --help form prints usage information for spfquery.
๐ OPTIONS ๐
๐ Standard Options ๐
The preferred and legacy forms optionally take any of the following OPTIONS:
--default-explanationstring,--def-expstring โ Use the specified string as the default explanation if the authority domain does not specify an explanation string of its own.--hostnamehostname โ Use hostname as the host name of the local system instead of auto-detecting it.--keep-comments,--no-keep-commentsโ Do (not) print any comments found when reading from a file or from standard input.--sanitize(currently ignored),--no-sanitize(currently ignored) โ 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 ๐ฎ
Several options that were supported by earlier versions of spfquery are considered black magic (i.e. potentially dangerous for the innocent user) and are thus disabled by default. 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-termsn โ 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-termn โ 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-foremail-address|domain,... โ Consider all the MXes of the comma-separated list of email-addresses and domains as inherently authorized.--tfwlโ Perform"trusted-forwarder.org"accreditation checking.--guessspf-terms โ Use spf-terms as a default record if no SPF record is found.--localspf-terms โ Process spf-terms as local policy before resorting to a default result (the implicit or explicit"all"mechanism 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.--overridedomain=spf-record,--fallbackdomain=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.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.neutralโ The identity's authority domain makes no assertion about the status of the IP address.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 ๐ง
bestie, the mapping is literally:
passโ exit code0failโ exit code1softfailโ exit code2neutralโ exit code3permerrorโ exit code4temperrorโ exit code5noneโ exit code6
๐ฅ 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 -
๐ COMPATIBILITY ๐
spfquery has undergone the following interface changes compared to earlier versions:
๐ฐ๏ธ 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
"unknown"and"error"result codes have been renamed to"permerror"and"temperror", respectively, in order to comply with RFC 4408 terminology. - 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"helo"scope directly. - The
--debugand--(no-)sanitizeoptions are currently ignored by this version ofspfquery. They will again be supported in the future. - 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:
--sender,-sโ preferred:--mfrom--ipv4,-iโ preferred:--ip-address,--ip--nameโ preferred:--hostname--max-lookup-count,--max-lookupโ preferred:--max-dns-interactive-terms--rcpt-to,-rโ preferred:--authorize-mxes-for--trustedโ preferred:--tfwl
๐ธ SEE ALSO ๐ธ
Mail::SPFspfd(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>.
k bye bestie ๐ โ this iconic page is from perl v5.42.1, dated 2026-04-02. periodt. ๐โจ
๐ฆ where this page comes from
- arch rolling: perl-mail-spf 3.20260331-1 ยท BSD-3-Clause
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms