Skip to content

Email DNS

Check a domain's SPF record

Parse the SPF record, count DNS lookups against the limit of 10, and flag the mistakes that make SPF fail.

Try an example

How to read the result

The header says Valid when the record has no errors and Invalid when it has at least one. A valid record that still carries warnings is marked as risky.

Field What it means What to do with it
Record The SPF record published at the domain. A TXT record split into several strings is joined without spaces, as RFC 7208 section 3.3 requires. Compare it with what you meant to publish. A typo made in a DNS panel shows up here first.
Records found How many TXT records at the domain start with v=spf1. It must be exactly 1. Two or more make every SPF evaluation end in permerror (RFC 7208 section 4.5), so merge them.
DNS lookups The terms that make a receiver query DNS, counted through every include and redirect: include, a, mx, ptr, exists and redirect. Shown against the limit of 10. Above 10, receivers return permerror and SPF fails for all your mail. See the section on getting under the limit.
Final "all" The result your record falls back to: fail for -all, softfail for ~all, neutral for ?all, pass for +all. When the record ends with a redirect, the checker follows it and shows the target's value. Empty when there is neither. fail and softfail are the useful values. pass lets any server on the internet send as you.
Mechanisms Every term of the record in order, with its qualifier, such as +include:_spf.example.net or -all. The modifiers redirect and exp are listed too. Receivers read left to right and stop at the first match. Nothing after all is ever read.
Issues A code for each problem found. Errors make the record invalid; warnings leave it valid but weaker. Each code is explained below. Fix every error, then decide on each warning.
Bulk CSV upload Locked. Verifies a CSV of email addresses; every row includes SPF and DMARC presence for the address's domain. Needs a free account.
API access Locked. The email endpoint returns domain.spf, true when the domain of an address publishes SPF, for 1 credit per address. It does not return the parsed record. Needs a free account, which includes 100 credits every month.

Issue codes: errors

Code Meaning
no_spf_record No TXT record at the domain starts with v=spf1. Receivers get the result none.
multiple_spf_records More than one SPF record. Receivers return permerror.
domain_not_found The domain does not exist (NXDOMAIN).
dns_error The TXT query failed: SERVFAIL, REFUSED or no answer in time.
syntax_error A term is malformed, such as all with an argument or include with a prefix length.
unknown_mechanism A term that is not an SPF mechanism, for example the typo inlcude:. Receivers return permerror.
missing_domain include: or exists: written without a domain.
invalid_domain_spec A domain or macro argument that is not well formed.
invalid_ip4, invalid_ip6 An ip4 or ip6 value that is not a valid address.
invalid_cidr A prefix length out of range: above /32 for IPv4 or above /128 for IPv6.
duplicate_modifier redirect or exp appears twice. RFC 7208 section 6 allows each one once.
too_many_dns_lookups More than 10 DNS-querying terms across the whole include tree.
too_many_void_lookups More than 2 include or redirect targets returned no records or did not exist.
include_no_spf, redirect_no_spf A target has no SPF record. RFC 7208 turns this into permerror, not a silent skip.
include_loop An include chain comes back to a domain already in the chain.
nested_multiple_spf_records A domain reached through include or redirect publishes several SPF records.
nested_record_invalid A record reached through include or redirect has errors of its own.

Issue codes: warnings

Code Meaning
permissive_all The record ends in +all, so every IP address passes.
neutral_all The record ends in ?all, so SPF says nothing about unlisted servers.
missing_all No all and no redirect. Receivers default to neutral (RFC 7208 section 4.7).
ptr_mechanism The record uses ptr, which RFC 7208 section 5.5 says should not be published.
terms_after_all Terms placed after all. Receivers ignore them.
redirect_ignored A redirect in a record that also has all. RFC 7208 section 5.1 says it is ignored.
unknown_modifier A name=value term other than redirect or exp. Receivers ignore it.
include_dns_error, redirect_dns_error A target's DNS query failed during the check. A receiver in the same situation returns temperror.
macro_not_expanded An include or redirect target is built with a macro such as %{i}, which depends on the message. It was not followed, so the lookup count may be low.
lookup_tree_truncated The include tree was too deep or too large to follow to the end.

How the check works

  1. The tool queries the TXT records of the domain over DNS over HTTPS, at Cloudflare's 1.1.1.1 resolver, with Google Public DNS as the fallback. NXDOMAIN stops the check with domain_not_found; any other failure stops it with dns_error.
  2. It keeps the records that start with v=spf1 and counts them. The strings of each TXT record are joined first.
  3. It splits the first record into terms. Each mechanism gets its qualifier (+ when none is written), its argument and its prefix length. redirect= and exp= are read as modifiers.
  4. It follows every include, and the redirect when the record has no all. Each target's SPF record is fetched and parsed, and its DNS-querying terms are added to the total. The walk is recursive, so an include inside an include counts too.
  5. Each include or redirect target that does not exist, or returns no records, counts as a void lookup.
  6. The totals are compared with the limits of RFC 7208 section 4.6.4: 10 DNS-querying terms and 2 void lookups.
  7. The final all is read from the record, or from the redirect target when the record delegates to it.

What the check cannot know:

  • Whether a given message passes. SPF compares the IP address of the connecting server with the record, and the tool does not know which servers send your mail.
  • Which domain receivers actually test. SPF checks the envelope sender, also called the Return-Path or MAIL FROM, and the HELO name. It does not check the From address people see. A sending service may use its own bounce domain, so check the domain in the Return-Path header of a message you received from it.
  • The inside of a and mx. The tool counts these terms but does not resolve the hosts behind them, so it cannot see the cap of 10 address lookups per mx term, or void lookups inside a, mx and exists.
  • Macros. Targets built from macros such as %{i} or %{d} depend on the message, so they are not followed.
  • Fresh edits. Resolvers cache TXT records for their TTL, so a change can take up to one TTL to show here.

SPF terms and what they cost

Term Matches when Counts toward the 10 lookups
ip4:192.0.2.0/24 The sending IPv4 address is in the range No
ip6:2001:db8::/32 The sending IPv6 address is in the range No
a or a:host.example.com The sending address is an A or AAAA address of the domain, or of the named host Yes, 1
mx or mx:example.com The sending address belongs to one of the domain's MX hosts Yes, 1, with at most 10 address lookups inside
include:_spf.example.net The included domain's own SPF evaluation returns pass Yes, 1, plus every lookup inside the included record
exists:%{i}.list.example.net The constructed name has an A record Yes, 1
ptr The sender's reverse DNS name ends in the domain; RFC 7208 says do not use it Yes, 1
all Always No
redirect=_spf.example.com Modifier: when nothing matched and there is no all, the target's result becomes yours Yes, 1
exp=explain.example.com Modifier: points to a text receivers can show when the result is fail No

include deserves a closer look. It does not paste the other record into yours. It runs the other domain's evaluation and matches only if that evaluation returns pass. A -all inside an included record therefore does not make your record fail: it only means that include did not match, and evaluation moves on to your next term.

SPF results

RFC 7208 section 2.6 defines seven results. The qualifier of the first matching term produces pass, fail, softfail or neutral.

Result Comes from What receivers do with it
pass A term with +, the default qualifier Treat the server as authorized.
fail A term with -, such as -all Treat the server as not authorized. A receiver may reject the message.
softfail A term with ~, such as ~all Should not reject on this result alone, but may scrutinize the message more closely (section 8.5).
neutral A term with ?, or no match with neither all nor redirect Must treat it exactly like none (section 8.2).
none No SPF record, or no domain to check No SPF information at all.
temperror A DNS failure during evaluation A temporary problem. The receiver may defer the message and retry.
permerror A broken record: several records, a syntax error, more than 10 lookups A permanent problem. SPF gives no protection until the record is fixed.

Getting under 10 DNS lookups

An include costs one lookup plus everything inside the record it points to, so a single include can spend several of your 10. Bring the count down in this order:

  • Remove includes for services that no longer send for you. Check every include against your current list of senders.
  • Replace a and mx with ip4 and ip6 ranges when the addresses rarely change. Those cost nothing.
  • Drop ptr. It costs a lookup and RFC 7208 says not to publish it.
  • Move a sending service to its own subdomain, such as news.example.com. SPF is evaluated on the envelope sender's exact domain, so each subdomain gets its own record and its own budget of 10.
  • Flatten only with automation. Replacing an include with the addresses it resolves to today saves lookups, but the provider can change those addresses at any time, and your record will not follow.

Before a campaign: check SPF for every sender

  1. List every service that sends mail as your domain: your mailbox provider, newsletter platform, CRM, help desk, billing system and any app that sends notifications.
  2. For each one, send yourself a message and read its Return-Path header. That domain is the one SPF evaluates.
  3. Check that domain here. Its record must cover the service, stay at 10 lookups or fewer and end in -all or ~all.
  4. Check alignment. DMARC counts an SPF pass only when the Return-Path domain aligns with the From domain: the same organizational domain in relaxed mode, the exact domain in strict mode. If a service keeps its own bounce domain, rely on DKIM signing with your domain instead, and confirm the key with the DKIM checker.
  5. Check your DMARC record last, since it decides what receivers do when both SPF and DKIM fail to align.

The SPF, DKIM and DMARC guide walks through the full setup, including records for domains that never send mail.

Same check through the API

One HTTPS call, one credit. The response below is the real schema returned by the API.

cURL
curl https://api.qelka.com/v1/email \
  -H "Authorization: Bearer sk_test_your_key" \
  -H "Content-Type: application/json" \
  -d '{"email":"jane@exmaple.com","mode":"fast"}'
JavaScript
const response = await fetch("https://api.qelka.com/v1/email", {
  method: "POST",
  headers: {
    Authorization: "Bearer sk_test_your_key",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    email: "jane@exmaple.com",
    mode: "fast",
  }),
});
const result = await response.json();
{
  "id": "lkp_01M84QZDZG5EJDJJE338NYR2ZA",
  "object": "email",
  "input": "jane@exmaple.com",
  "status": "unknown",
  "reason": "smtp_not_checked",
  "did_you_mean": "jane@example.com",
  "checks": {
    "syntax": true,
    "mx": true,
    "smtp": null,
    "catch_all": null,
    "disposable": false,
    "role": false,
    "free_provider": false
  },
  "domain": {
    "name": "exmaple.com",
    "spf": true,
    "dmarc": true
  },
  "score": 55,
  "credits_used": 1,
  "cached": false
}

Bulk and pricing

  • Upload a CSV of up to 2,000,000 rows from the dashboard or the API, pick the column, get the results back as a CSV.
  • Every check costs 1 credit, live phone lookups cost 3. Cached results are billed the same way; calls that fail upstream are not billed.
  • The free plan includes 100 credits every month. Paid plans start at $29 for 10,000 credits.

Frequently asked questions

What is an SPF record?
SPF (Sender Policy Framework, RFC 7208) is a TXT record that lists the servers allowed to send mail for a domain. It starts with v=spf1, then lists IP ranges and includes for third-party services, and ends with an all rule for everyone else. Receiving servers compare the connecting IP address with the record and get a result such as pass, fail or softfail.
How do I fix "SPF permerror: too many DNS lookups"?
It means a receiver counted more than 10 terms that query DNS, across your record and every record it includes, and gave up. Remove includes for services you no longer use, replace a and mx with ip4 and ip6 ranges where the addresses are stable, drop ptr, and move a high-volume sender to a subdomain with its own record. Check again until the count reads 10 or less.
Which SPF mechanisms count toward the 10 lookup limit?
include, a, mx, ptr and exists count, plus the redirect modifier, wherever they appear in the include tree (RFC 7208 section 4.6.4). ip4, ip6 and all cost nothing, and exp is only looked up after a fail. Each mx also has its own cap of 10 address lookups for the mail hosts it names.
What is a void lookup in SPF?
A void lookup is a DNS query made during SPF evaluation that returns no records, or a name that does not exist. RFC 7208 recommends that receivers allow at most two, and going over gives permerror. A typical cause is an include pointing at a domain that was deleted or renamed, so clean those up even when the 10 lookup total looks fine.
Should I end my SPF record with -all or ~all?
Both work with DMARC, which counts only an aligned pass, so fail and softfail are equally a miss there. -all tells receivers that unlisted servers are not authorized; ~all asks them not to reject on SPF alone. Start with ~all while you are still finding every service that sends for you, and move to -all once your DMARC reports show all of them passing.
Can a domain have two SPF records?
No. If a domain publishes more than one TXT record starting with v=spf1, receivers stop with permerror and SPF fails for every message (RFC 7208 section 4.5). This happens when a second service's setup guide says to add a record and nobody merges it with the first. Combine all the mechanisms into one record with a single all at the end.
What does +all mean in an SPF record?
+all makes every IP address on the internet pass SPF for your domain. It defeats the purpose of the record: anyone can then send mail that passes SPF as you. The checker reports it as permissive_all. Replace it with ~all or -all, after making sure every legitimate sending service is listed before it.
Does SPF protect the From address people see?
Not by itself. SPF checks the envelope sender, also called the Return-Path or MAIL FROM address, and the HELO name of the connecting server. The visible From header can name a different domain and still pass SPF. DMARC closes that gap by requiring the SPF-checked domain, or the DKIM signing domain, to align with the From domain.
Is SPF flattening a good idea?
Flattening replaces includes with the IP ranges they currently resolve to, which cuts the lookup count. The risk is drift: when a provider adds or changes its sending ranges, your flattened record does not follow, and mail from the new ranges fails SPF. Only flatten with automation that re-resolves the includes and republishes your record when they change.
How long can an SPF record be?
Each string inside a TXT record holds at most 255 characters (RFC 1035), so a longer record is split into several quoted strings that receivers join without spaces. RFC 7208 section 3.4 asks that the whole answer stay small enough to fit in 512 bytes. A record that keeps growing usually lists ranges an include could cover, so consolidate before you split.
Do subdomains inherit the SPF record of the main domain?
No. SPF is evaluated for the exact domain in the envelope sender or the HELO name, with no fallback to the parent. news.example.com needs its own record if it sends mail. A subdomain that never sends mail can publish v=spf1 -all to say so. DMARC works differently and does fall back to the organizational domain.
Why does SPF pass while DMARC fails?
SPF passed for a domain that does not align with your From address. When a sending platform puts its own bounce domain in the Return-Path, SPF passes for the platform's domain, not yours. Fix it with a custom Return-Path on a subdomain of your domain, or by signing with DKIM under your own domain. Check both with the DMARC checker.
Is the ptr mechanism still allowed?
Receivers still have to support it, but RFC 7208 section 5.5 is titled "ptr (do not use)" and says the mechanism should not be published. It is slow, depends on reverse DNS controlled by whoever owns the connecting IP, and costs one of your 10 lookups. Replace it with ip4 or ip6 ranges for the servers it was meant to cover.
What is the difference between softfail and neutral?
~all gives softfail: the domain says the server is probably not authorized, and receivers may look at the message more closely but should not reject it on that alone. ?all gives neutral: the domain makes no statement, and RFC 7208 section 8.2 says receivers must treat it exactly like having no SPF record. Neutral protects nothing.
Can I check SPF through the API?
The email endpoint reports SPF presence for the domain of every address it verifies, in the domain.spf field, for 1 credit per address. It does not return the parsed record or the lookup count; this tool does that, with 10 free checks a day without an account. The email endpoint reference lists the other domain checks.

Put this check in your product

Get an API key in under a minute. 100 free credits every month, no card required.