SPFQUERY(1)
๐ NAME ๐
okay so bestie, meet spfquery and spfquery.libspf2 โ they check whether an IP address is an SPF-authorized SMTP sender for a domain. that's the whole vibe. no cap. ๐ฆ
this page lives in the libspf2 manuals for Debian and is literally titled SPFQUERY(1), iykyk.
๐ธ SYNOPSIS ๐ธ
three whole ways to run her, pick your fighter:
spfquery {-i|--ip} ip-address {-s|--sender} [local-part@]domain
[{-h|--helo} domain-name] [--rcpt-to email-address(es)]
[CONTROL-OPTIONS]
spfquery {-f|--file} datafile [CONTROL-OPTIONS]
spfquery {--help|-v|--version}
โจ DESCRIPTION โจ
this manual page documents briefly the spfquery command. it was written for the Debianยฎ distribution because the original program does not have a manual page โ so we made one, you're welcome. ๐
spfquery performs Sender Policy Framework (SPF) authorization checks based on the command-line arguments or data given in a file or on standard input. for information on SPF see http://www.openspf.org. go read it, it's giving lore. ๐
๐ OPTIONS ๐
so the options are split into two groups, and this matters:
- Data options โ these must be given, though just enough of them to specify a query.
- Control options โ these are optional and control the local policy, behaviour and output format of
spfquery.
This programs follows the GNU getopt_long_only(3) command line syntax: long options can be given with one or two dashes and can be abbreviated to a prefix long enough to be non-ambiguous. If an option starting with a single dash doesn't match a long option, it is taken as a short option with a following parameter, if applicable. An equals sign between the option name and the parameter is optional for both short and long options. slay, flexible queen. ๐
๐งบ Data options
the --file option conflicts with all the other data options, bestie, do not mix. the --helo and --rcpt-to are optional.
-f,--filefilename โ Read SPF data from filename. Specify-to read from standard input.
The file should consist of one line per query, each query line consisting of the IP address, sender adress, and optional HELO string, separated by spaces.
Note: Local parts containing spaces are currently not supported. ๐ (the typo "adress" is theirs, we're keeping it, it's canon now)
-i,--ipip-address โ Specify the IP address of the remote host that is delivering the mail.-s,--sender[local-part@]domain โ Specify the email address that was used as the envelope sender. If no username (local part) is given,postmasterwill be assumed. she's assuming, periodt. ๐-h,--helodomain-name โ Specify that domain-name was provided in the SMTP HELO (or EHLO) command.-r,--rcpt-torcpt-address[,rcpt-address,...] โ Specify the recipients as comma-separated list. Any secondary mail exchangers of all recipient domains are automatically authorized. automatic slay. ๐ฅ
๐๏ธ Control options
-d,--debug[=level]โ Turn on debugging output.-l,--localspf-terms โ Test against spf-terms before the final (implicit or explicit)allin an SPF record. This can be used to implement a local policy for whitelisting.-t,--trusted [1]โ Check the sender domain withtrusted-forwarder.org. This is a non-standard feature. (non-standard!! she said it, not me, but we trust her anyway ๐ซถ)-t 0,--trusted 0โ Do not check the sender domain withtrusted-forwarder.org. This is the default.-g,--guessspf-mechanisms โ Test the sender domain against spf-mechanisms if the domain has no SPF record.-e,--default-explanationstring โ Default explanation string to use if the SPF record does not specify an explanation string itself.-m,--max-lookupnumber โ Maximum number of DNS lookups to allow.-c,--sanitize [0|1]โ Do [not] sanitize the output by condensing consecutive whitespace into a single space and replacing non-printable characters with question marks. Enabled by default.-n,--namehostname โ Use hostname as the name of the local system instead ofspfquery(the name is used in the output).-k,--keep-commentsโ Print comments found when reading from a file.-a,--override ...โ (see--fallbackbelow)-z,--fallback ...โ Provide override and fallback SPF records for certain domains. Not implemented yet.spfquerywould act as if the specified records were present before and after any existing record, respectively, of those domains. (not implemented yet!! don't come for her, she's just a girl ๐ธ)--helpโ Show summary of options.-v,--versionโ Show version of program.
๐ฉบ DIAGNOSTICS ๐ฉบ
the output ordinarily consists of four lines, in this order, no skipping:
- the result code;
- the explanation, suitable for use in an SMTP response message, empty except when a rejection (permanent or temporary) makes sense;
- the header comment on its own;
- the
Received-SPFheader field as defined in RFC 4408 section 7, incorporating the header comment.
if errors (including no SPF record found!) occur during processing, one or more error blocks will be prepended. these start with StartError and end with EndError.
the result codes and their corresponding exit codes are as follows, memorise them bestie:
1โ neutral โ The sender domain explicitly makes no assertion about the ip-address. This result must be interpreted exactly as if no SPF record at all existed.2โ pass โ The ip-address is authorized to send mail for the sender domain. (we love to see it ๐)3โ fail โ The ip-address is unauthorized to send mail for the sender domain.4โ softfail โ The ip-address is not authorized to send mail for the sender domain, but the sender domain cannot or does not wish to make a strong assertion that no such mail can ever come from it. she's being diplomatic about it ๐5โ none โ No SPF record was found.6โ error (temporary) โ A transient error occurred (e.g. failure to reach a DNS server), preventing a result from being reached.7โ unknown (permanent error) โ One or more SPF records could not be interpreted.
๐งช EXAMPLES ๐งช
copy-paste these, they're iconic:
spfquery -ip=11.22.33.44 -sender=user@aol.com -helo=spammer.tld
spfquery -f test_data
echo "127.0.0.1 myname@mydomain.com helohost.com" | spfquery -f -
๐ SEE ALSO ๐
spftest(1), spfd(8)
๐ AUTHOR ๐
spfquery was written by Wayne Schlitt.
This manual page was written by Magnus Holmgren for the Debianยฎ system (but may be used by others). Heavily inspired by the spfquery manpage of libmail-spf-query-perl (spfquery.mail-spf-query-perl(1)) by Julian Mehnle. Also based on the command-line help of spfquery. giving credit where credit is due, as she should. ๐ซถ
โ๏ธ COPYRIGHT โ๏ธ
Copyright ยฉ 2007 Magnus Holmgren. Permission is granted to copy, distribute and/or modify this document under the terms of the two-clause BSD License. See /usr/share/doc/spfquery/copyright.
and that's the whole page bestie!! ๐ libspf2 1.2.5, dated 2007-09-06 โ vintage, iconic, still serving. mwah ๐โจ
๐ฆ where this page comes from
- debian bookworm: spfquery 1.2.10-7.2+b1
- debian trixie: spfquery 1.2.10-8.3
- ubuntu jammy: spfquery 1.2.10-7.1ubuntu1
- ubuntu noble: spfquery 1.2.10-8.1ubuntu3
- ubuntu questing: spfquery 1.2.10-8.3
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms