spf-lookups
Count the DNS lookups of an SPF record – including every nested include and redirect – and see which entry breaks the limit.
RFC 7208 allows at most 10 DNS lookups and 2 void lookups per SPF evaluation. Above that, receivers return permerror, SPF no longer counts for DMARC, and mail that relies on SPF alignment starts to fail. Every SaaS sender you add (newsletter, ticketing, CRM, invoicing) usually adds another include, so domains cross the limit without anyone noticing.
$ spf-lookups example.com
example.com [9 lookups]
v=spf1 include:_spf.mail.test include:send.test a mx ip4:192.0.2.1 -all
include:_spf.mail.test [2 lookups]
v=spf1 include:_a.mail.test include:_b.mail.test ~all
include:_a.mail.test [0 lookups]
v=spf1 ip4:198.51.100.0/24 ~all
include:_b.mail.test [0 lookups]
v=spf1 ip6:2001:db8::/32 ~all
include:send.test [3 lookups]
v=spf1 exists:%{i}.rbl.send.test redirect=_spf.send.test
redirect:_spf.send.test [1 lookup]
v=spf1 a:out.send.test -all
DNS lookups: 9 of 10
Void lookups: 0 of 2
Result: OK
Install
pip install spf-lookups
Requires Python 3.9+ and dnspython.
Usage
spf-lookups example.com # tree and totals
spf-lookups example.com --json # machine-readable
spf-lookups example.com --timeout 3
Exit codes, for scripts and CI: 0 within limits · 1 limit exceeded or permerror · 2 no SPF record or DNS error.
What is counted
| Term | Lookups |
|---|---|
include, a, mx, ptr, exists, redirect |
1 each, plus everything inside an included or redirected record |
ip4, ip6, all, exp |
0 |
redirect when all is present |
0 (ignored, RFC 7208 6.1) |
It also reports void lookups (NXDOMAIN or empty answers), includes pointing to domains without SPF, more than one SPF record, loops, ptr (deprecated) and mx targets with more than 10 hosts. Macros such as %{i} are counted, but their target can only be resolved by the receiver.
How to get below 10
- Remove services you no longer use.
- Take services out of SPF that sign with DKIM in your domain – DMARC passes on aligned DKIM alone.
- Move bulk senders to a subdomain with its own SPF record (
news.example.com). - Flattening (IP addresses instead of
include) only with monitoring: providers change their ranges without notice.
Web version and DMARC
No install needed: the same check runs in the browser at igs.ch – SPF lookups, next to a DMARC report reader and a DMARC record builder. To check SPF, DKIM, DMARC and MTA-STS of a whole domain at once: free DMARC check.
spf-lookups is maintained by Inbox Guard Switzerland, a Swiss service that takes domains safely from DMARC p=none to p=reject.
License
MIT
Metadata
Release files for spf-lookups 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spf_lookups-1.0.1.tar.gz | 9.3 kB | With provenance | Details for spf_lookups-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spf_lookups-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for spf_lookups-1.0.1-py3-none-any.whl |
Total release size: 17.3 kB
Release files / spf_lookups-1.0.1.tar.gz
| Download URL | spf_lookups-1.0.1.tar.gz |
|---|---|
| Size | 9.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1ba5fed55edcbadba43529fe4f9df1cf619f33b55d4d931f9635177cf8277977
|
|
BLAKE2b-256 checksum How to use checksums |
6cfd4e981a5b4dcfc9e48b69c0ffbb7d4bb3e6fa78875fe86274e9b6d397d481
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logRelease files / spf_lookups-1.0.1-py3-none-any.whl
| Download URL | spf_lookups-1.0.1-py3-none-any.whl |
|---|---|
| Size | 8.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1811cfd1685df7fa66d6f7fa2e40f2b81d675918cec51b3a32f40992836c6990
|
|
BLAKE2b-256 checksum How to use checksums |
3123c9638e3ab5fe1c7e71471b1a53ea662f346acfe7744c74b48fc75c39863e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logSecurity for spf-lookups 1.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for spf_lookups-1.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 20, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.