Since February 2024, Gmail and Yahoo require bulk senders to publish SPF, DKIM and a DMARC record. Most domains have "something" in DNS, which is exactly the problem: a record that exists but is broken fails silently. Mail lands in spam or is rejected, and nothing on your side reports an error.
Here are the failures worth checking, how to check one domain with tools you already have, and how to audit a long list.
The four silent failures
1. SPF needs more than 10 DNS lookups. RFC 7208 caps the lookups a receiver performs while evaluating SPF at 10. Each include:, a, mx, exists: and redirect= costs one, and includes are followed recursively. Add one SaaS tool too many and the whole record returns a permanent error. The record still looks fine to the eye.
2. Two SPF records. A domain must publish exactly one v=spf1 record. Two (often one per provider) is also a permanent error.
3. DMARC stuck on p=none. p=none only asks for reports. Anyone can still send mail as your domain until the policy is quarantine or reject.
4. SPF that ends in +all or has no all. +all authorizes the whole internet.
Option A: dig or nslookup for one domain
dig +short TXT example.com | grep spf1
dig +short TXT _dmarc.example.com
dig +short TXT google._domainkey.example.com
On Windows: nslookup -type=TXT _dmarc.example.com.
The first line shows the SPF record, the second the DMARC policy. The third checks one DKIM selector (google is the default for Google Workspace). DKIM selectors cannot be listed from DNS: you find the right one in the DKIM-Signature: s= header of a message the domain sent.
What dig does not tell you is the lookup count: you would have to follow every include by hand.
Option B: a short Python script that counts SPF lookups
With pip install dnspython:
import dns.resolver
def txt(name):
try:
return [b"".join(r.strings).decode() for r in dns.resolver.resolve(name, "TXT")]
except (dns.resolver.NXDOMAIN, dns.resolver.NoAnswer):
return []
def spf_lookups(domain, seen=None):
seen = seen or set()
if domain in seen:
return 0
seen.add(domain)
records = [t for t in txt(domain) if t.lower().startswith("v=spf1")]
if len(records) != 1:
return 0
n = 0
for term in records[0].split()[1:]:
t = term.lstrip("+-~?").lower()
if t.startswith(("include:", "redirect=")):
n += 1 + spf_lookups(t.split(":", 1)[-1].split("=", 1)[-1], seen)
elif t in ("a", "mx", "ptr") or t.startswith(("a:", "a/", "mx:", "mx/", "exists:", "ptr:")):
n += 1
return n
for line in open("domains.txt", encoding="utf-8"):
d = line.strip()
if not d:
continue
spf = [t for t in txt(d) if t.lower().startswith("v=spf1")]
dmarc = [t for t in txt("_dmarc." + d) if t.lower().startswith("v=dmarc1")]
policy = dmarc[0].replace(" ", "").split(";p=")[-1].split(";")[0] if dmarc else "missing"
n = spf_lookups(d)
bad = len(spf) != 1 or n > 10 or policy in ("missing", "none")
print("BAD" if bad else "OK ", d, f"spf_records={len(spf)} lookups={n} dmarc={policy}")
It covers failures 1 to 3 for a list of domains. Limits of this script: SPF macros are not expanded, DKIM is not checked, and DNS errors other than "no such record" will raise.
Option C: a hosted checker for bulk audits
Disclosure: this one is ours. We publish SPF, DKIM & DMARC Checker on Apify. You paste domains (URLs and e-mail addresses work too, only the domain is used) and each row comes back with SPF, DMARC, DKIM on 19 common selectors, MTA-STS, TLS-RPT, BIMI and MX, a score out of 100, a grade from A to F and a list of issues.
from apify_client import ApifyClient # pip install apify-client
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("extas_corp/email-auth-checker").call(run_input={"domains": ["example.com"]})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item["domain"], item.get("grade"), item.get("issues"), item["error"])
A domain that receives mail but publishes neither SPF nor DMARC comes back like this (shortened):
{
"domain": "badssl.com",
"ok": false,
"score": 30,
"grade": "F",
"issues": [
"no SPF record",
"no DMARC record",
"no DKIM key on the selectors tried (the domain may use another selector)",
"no MTA-STS (optional): inbound mail TLS is not enforced"
]
}
ok is true when there is exactly one SPF record ending in -all or ~all within 10 lookups, and a DMARC policy of quarantine or reject. The local part of report addresses is masked (mailto:*@domain), so no e-mail address appears in the output.
It is free during launch: you only pay Apify's own platform usage, which the free monthly credit covers for normal use. Limits: a DKIM selector outside the list is reported as "no DKIM key on the selectors tried" unless you add it to dkimSelectors; SPF macros are counted but not followed; it reads DNS only, so it does not send mail, test SMTP servers, check blocklists or verify that signatures validate.
What to do with the results
- Over 10 lookups: remove includes for tools you no longer use before anything else.
-
p=none: read the aggregate reports for a few weeks, fix the legitimate senders that fail, then move toquarantine. - Check every domain you own, including the ones that send no mail: publish
v=spf1 -allandp=rejecton those so nobody else can use them.
Top comments (0)