SPFQUERY(1p)

๐Ÿ“ฆ
version 3.20260331 ยท 4 versions
, in ubuntu stonking

๐Ÿ’– 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:

  • 1 means v=spf1 records should be used.
  • 2 means spf2.0 records 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 to 10. 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 to 10. 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 โ€” perform trusted-forwarder.org accreditation 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 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.
  • --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 --identity option and an optional --scope option 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. 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 helo scope directly. No cap. ๐Ÿšซ
  • The --debug and --(no-)sanitize options are currently ignored by this version of spfquery. They will again be supported in the future. She's on a break. ๐Ÿ˜ด
  • Several features that were supported by earlier versions of spfquery are 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