Blog

How to Check an SPF Record

Confirm one v=spf1 TXT record with dig, nslookup or the SPF checker. See what a missing record, a duplicate and a permerror each mean.

The job is a small one. Confirm that the domain has exactly one TXT record starting with v=spf1, and that a receiver can evaluate it. A domain can fail that job in three different ways, and the fixes are not the same.

A missing record means there is no v=spf1 text at the name you asked about. Receivers treat that as none. Nothing is authorized, and SPF is not failing anyone either. A duplicate record means two TXT answers at that name both start with v=spf1. Receivers do not merge them. Evaluation stops with a permanent error. A permerror is the third outcome. The record exists, and it is the only one, but the receiver cannot finish evaluating it. The usual reason is too many DNS lookups. A permerror is a different result from a missing record, and it is a different result from the soft fail you get when a sender simply is not on the list.

Check the name the receiver will actually use. SPF looks at the envelope sender, often called the MAIL FROM or the return path. That can be a subdomain such as mail.example.com even when the message people see is from hello@example.com. If you look up the wrong name, a perfect record on the other name will look missing.

Read the TXT record with dig

dig asks the DNS system and prints the answer. This asks for TXT records only:

bash
dig TXT example.com +short

The sample below is the shape of a healthy answer, written as an example. It is not a live lookup you should copy for your own domain.

text
"v=spf1 include:_spf.example.net ip4:192.0.2.10 -all"
"google-site-verification=abc123"

Two lines came back. Only the line that starts with v=spf1 is SPF. The verification string is a different TXT record. Leave it in place, and do not paste it into the SPF record.

DNS can also split one long TXT value into quoted pieces of 255 characters. Those pieces are still one record when they sit in a single answer. dig +short usually prints them on one line, one pair of quotes after another:

text
"v=spf1 include:_spf.example.net " "ip4:192.0.2.10 -all"

Join the quoted pieces and you have one policy: v=spf1 include:_spf.example.net ip4:192.0.2.10 -all. Two separate answers that each start with v=spf1 are the duplicate case. A DNS panel that stores one box as several strings is still one record. Two boxes are not.

If dig prints nothing, the name has no TXT records. If it prints TXT records and none of them start with v=spf1, the SPF record is missing even though the name is not empty. A timeout or a SERVFAIL is not an empty answer. Ask again before you publish a record on top of one you could not see.

Read it with nslookup

nslookup is on macOS, Windows and many Linux machines. Ask for the TXT type by name:

bash
nslookup -type=TXT example.com

An example of the interesting part of the reply:

text
example.com text = "v=spf1 include:_spf.example.net ip4:192.0.2.10 -all"

The text after text = is the record. One v=spf1 string is what you want. A second text = line that also starts with v=spf1 is a duplicate. Anything else in a text = line is not SPF. When the result surprises you, repeat the query against a public resolver so you are not reading a stale cache: nslookup -type=TXT example.com 1.1.1.1.

Read it with PowerShell

On Windows, Resolve-DnsName prints the TXT strings as a list. This is the command:

powershell
Resolve-DnsName example.com -Type TXT

An example of the columns that matter:

text
Name         Type TTL  Strings
----         ---- ---  -------
example.com  TXT  300  {v=spf1 include:_spf.example.net ip4:192.0.2.10 -all}

Strings holds the record. Several chunks inside one pair of braces are still one TXT record. A second TXT row whose strings also start with v=spf1 is a second record. Add -Server 1.1.1.1 when you want to bypass the resolver Windows is using.

What a good record looks like

A usable record has three parts, in this order. The version, the senders you mean to allow, and a final all.

text
v=spf1 include:_spf.example.net ip4:192.0.2.10 -all

v=spf1 has to be exact, including the capitalisation. V=SPF1 is not a version receivers keep. After the version, each word is a mechanism. include:_spf.example.net tells the receiver to evaluate that other domain's SPF record. ip4:192.0.2.10 allows one address, and a prefix such as ip4:192.0.2.0/24 allows a range. ip6: does the same for IPv6. a, mx, exists and ptr are the other mechanisms that cause DNS lookups. ptr is a poor fit for a record you control. Prefer a name or an address you can list on purpose.

The last word decides what happens when nothing earlier matched. ~all is a soft fail. The sender is not on the list, and you are asking receivers to treat that as a weak failure. That is a reasonable choice while you are still finding every service that sends as the domain. -all is a fail. The sender is not on the list, and you want SPF to fail them. Move to -all once the list is complete. +all, or a bare all, matches every sender and returns pass. It publishes that any server on the internet may send as your domain. Do not use it. ?all matches everyone and returns neutral, which does not help you. A record with no all and no redirect also ends as neutral for anyone who did not match. Neutral is not a pass, and it is not a fail.

redirect= is not another word for include:. An include that does not pass is skipped, and evaluation continues. A redirect is used only when nothing else matched, and the other domain's result replaces yours. Most domains want one include per provider and a single all.

Copy the include host from the provider that sends the mail. If several products send as the same domain, add each of them to the record you already have. A second v=spf1 next to the first one is the duplicate described above.

Let the SPF checker follow the includes

dig, nslookup and Resolve-DnsName show the TXT record on the name you typed. They do not open include: or redirect= and they do not count lookups. That second step is what the SPF checker is for. Paste the domain, not a URL and not an email address. The first result is the live lookup: the record, the include tree, and a running total of lookup-triggering terms against the limit of 10.

Read the tree from the top. The root is the name you asked about, and each child is an include or a redirect. The number on a node is the lookup terms on that record. The running total is the inventory after that branch. include, a, mx, ptr, exists and redirect count. ip4, ip6 and all do not. The total can sit over 10 because every branch is walked. A real message uses one path and stops at the first match, so a receiver may do less. The number describes the record. It is not, by itself, a pass or a fail.

Under the lookup, test a sending IP. You give the address of a server that sends the mail, and the checker walks one path. The result is pass, fail, softfail or neutral, and it names the mechanism that matched. Without that IP, the page is an inventory, not a full check_host evaluation. The IP test does not expand macros or evaluate ptr. If the record needs either before another mechanism matches, the result is reported as not evaluated.

If you are about to change DNS, use "Test this draft record" on that page before you publish. Paste the TXT value. It checks that the text starts with one v=spf1, flags a second record, flags +all, and checks the mechanisms it recognizes. Includes in the draft are looked up so the count includes them. The draft test does not write anything to DNS.

When the number is the problem

If the tree is deep, or the running total is near 10, stop and read SPF permerror before you edit. That guide is about the limit itself: which mechanisms count, why one message uses one path, and why deleting an old include is the change that usually fixes a permerror. This page will not repeat that explanation. Use it when the record is present and unique, and the failure is that receivers cannot finish walking it.

A mail log that says permerror, or "too many DNS lookups", points at that guide. An empty TXT answer is the missing-record case. Two v=spf1 answers are the duplicate. Adding another include does not repair a permerror, and a second record does not repair a missing include.

What a passing record does not prove

A record that looks right, and an IP test that returns pass, prove a narrow thing. For that address, SPF matched a mechanism and returned that result. They do not prove the message will reach the inbox. Content, complaint history and the reputation of the connecting address still matter.

They also do not prove DMARC alignment. SPF checks the envelope domain. DMARC asks whether that domain lines up with the visible From domain, or whether DKIM does. A pass on mail.example.com can still fail DMARC for mail From example.com when the domains are not aligned and DKIM does not pass. Check the public key with the DKIM checker and the policy with the DMARC checker. SPF, DKIM and DMARC explained is the short map of the three.

The checkers read public DNS. They do not open a mailbox, and they do not send a message. After you publish the record you meant to publish, send a message to a mailbox you can inspect and read the Authentication-Results header. That is the SPF result the receiver actually produced.

Before you change the record

List every service that still sends as the domain, and remove the include for anything that no longer does. Keep the rest in the same TXT record. If SendPanda is one of the senders, copy the SPF name and value from the domain screen. The domain setup guide explains which name gets which record. Do not replace a whole policy with one provider's example while other services still send as that domain.

Publish the edited record, wait for the old TTL to pass, and run the lookup again. Included providers change their own records without telling you, so a total that was fine in March can be over the line in November. The SPF checker is the place to see the tree and the count after you do.

Send your first email today.

Start free and connect your domain in a few minutes.