Skip to content

Home / Blog

Guide

SPF Records Done Right: How to Avoid Common Mistakes

SPF Records Done Right: How to Avoid Common Mistakes

An SPF record is a TXT record in your domain’s DNS that lists the servers and services allowed to send email as your domain. To work, your domain needs exactly one SPF record that starts with v=spf1, names every service that sends for you, stays within 10 DNS lookups, and ends with ~all or -all. Most email problems that start right after adding a new tool come from breaking one of those rules.

Our guide to business email on your own domain introduced MX, SPF, DKIM and DMARC. This article goes deep on SPF alone.

What does an SPF record actually check?

An SPF record answers one question for the receiving server: is the server that just handed me this message allowed to send for this domain? SPF stands for Sender Policy Framework, and the current standard is RFC 7208 from the IETF.

What many people miss: SPF does not check the From address readers see. It checks the return-path (MAIL FROM), where bounces go, and the name the sending server announces when it connects (HELO). A spoofed message can pass SPF while faking your From address, which is why DMARC requires the domain that passed to match the From domain. Google’s email sender guidelines require every sender to set up SPF or DKIM, and anyone sending more than 5,000 messages a day to Gmail to set up both, plus DMARC.

How do you read an SPF record?

An SPF record is read from left to right, and the first term that matches the sending server decides the result. Take this example:

v=spf1 a mx ip4:203.0.113.10 include:_spf.mail-service.example ~all
Term What it means
v=spf1 Required version tag; it must come first
a Allow the IP address the domain’s A record points to
mx Allow the servers listed in the domain’s MX records
ip4: / ip6: Allow a specific IP address or range
include: Allow whatever another domain’s SPF record allows; this is how you add third-party services
exists: An advanced mechanism small sites rarely need
ptr Legacy mechanism the standard says should not be published; avoid it
all Matches everything, so it goes last and decides what happens to anyone not listed

Each mechanism can carry a qualifier that sets the result on a match: + pass, - fail, ~ softfail and ? neutral. With no qualifier the default is +, so a and +a mean the same thing. There is also the redirect= modifier, which hands the whole check to another domain’s record; the standard ignores it if the record contains all.

How do I write an SPF record for my domain?

List every sender first, then build a single line that covers all of them.

  1. Inventory everything that sends as your domain: your hosting server (everyday mail and website forms), your mailbox provider (such as Google Workspace or Microsoft 365), your newsletter tool, and any invoicing or CRM system that emails customers in your name.
  2. Take each service’s value from its official documentation, not from old forum posts.
  3. Build one record. Start with v=spf1, add the mechanisms, and finish with ~all, with a single space between terms.
  4. Publish it in the right place. Add the record in the DNS zone your nameservers point to. If they point to your host, records added at the registrar are ignored.
  5. Test it, as described at the end of this article.

A domain that sends from its hosting and from a newsletter tool would look like this:

v=spf1 a mx include:_spf.newsletter.example ~all

Why can a domain only have one SPF record?

Because the standard says so: if the receiver finds more than one record starting with v=spf1 on the same name, the result is a permerror, a permanent error that leaves your domain with no valid SPF at all. This is the single most common SPF mistake.

It usually happens like this. A newsletter tool tells you to “add an SPF record”, so you add a new one next to your host’s:

v=spf1 a mx ~all
v=spf1 include:_spf.newsletter.example ~all

Now the check fails for both. The fix is to merge them into one line and delete the extra record:

v=spf1 a mx include:_spf.newsletter.example ~all

Other TXT records, such as site verification tokens, can coexist; the rule applies only to records starting with v=spf1.

What is the SPF 10-lookup limit, and how do I stay under it?

RFC 7208 caps a single SPF check at 10 terms that require a DNS lookup; go over and the result is permerror. The terms that count are include, a, mx, ptr and exists, plus the redirect modifier. ip4, ip6 and all do not count.

The hidden trap is that lookups inside each include count too. If a provider’s record contains three includes of its own, adding it costs four lookups, not one, so a short-looking record can already be over the limit.

The standard adds two smaller limits: “void” lookups that return nothing should be limited to two, and each mx mechanism must not trigger more than 10 address lookups.

Ways to stay under the limit:

  • Remove the include for any service you no longer use. It is the easiest saving and the most often forgotten.
  • If a and mx point to the same server, one may be enough. If the server’s address is stable, ip4: does not count as a lookup, but remember to update it when the server changes.
  • Move campaign mail to a subdomain such as news.example.com with its own SPF record. SPF is not inherited, so every name has its own budget.
  • Be careful with “flattening”, replacing includes with hard-coded IP addresses. Providers change their addresses, so a flattened record quietly goes stale unless a tool keeps it updated.

SPF ~all or -all: which should you use?

Use ~all until you are sure the record lists every sender, then move to -all, ideally once DKIM and DMARC are also in place.

Ending Result In practice
-all fail Unlisted servers are explicitly not authorised
~all softfail Probably not authorised; be suspicious, do not reject on this alone
?all neutral The domain takes no position; of little use
+all pass Every server on the internet is authorised; a serious mistake

The standard describes softfail as somewhere between fail and neutral, and says receivers should not reject mail on softfail alone. cPanel’s Email Deliverability tool recommends ~all by default and warns that its -all option makes every undefined host fail, so it should be enabled with care.

If you forget a service that sends as you, such as a booking tool, -all can get its mail rejected, and some receivers reject on an SPF fail before looking at DKIM, which hurts forwarded mail.

Common SPF record mistakes

  • Two or more SPF records on the same domain. Merge them.
  • Typos: missing v=, v=spf1 not at the start, curly quotes pasted from a word processor, or include without its colon.
  • Terms after all. Nothing after all is ever reached, because all matches everything.
  • Including a domain with no SPF record. The standard returns permerror, so check the exact value in the provider’s docs.
  • Strings over 255 characters. Each string inside a TXT record is limited to 255 characters, and a long record is split into several quoted strings that are joined without spaces, so put the separating space inside a string yourself.
  • Forgetting domains that never send mail. The standard recommends publishing v=spf1 -all on them so nobody can use them for spoofing.
  • Not updating after a host move. If the record lists the old server’s IP, add the new one and remove the old. Our guide to migrating WordPress without downtime reminds you to plan for email during the move.

How do I check that my SPF record works?

Three quick checks cover most cases:

  1. cPanel’s Email Deliverability tool shows SPF status for each domain, suggests a corrected record when something is wrong, and offers a Repair button when your host runs the domain’s DNS.
  2. Send a test to a Gmail account, open it, choose Show original, and look for spf=pass.
  3. From the command line, dig TXT example.com +short lists every TXT record so you can confirm there is only one SPF record.

Every Start Bigger hosting plan comes with cPanel and its Email Deliverability tool, and our support covers email and DNS issues, so you can ask us to review your record. Outgoing mail is limited to 100 messages per hour per domain under our acceptable use policy, so send campaigns through a dedicated sending service and add its include to your existing record, not a new one. For the other record types, see DNS records explained simply.

In short

  • One SPF record per domain, starting with v=spf1; a second record breaks the check entirely.
  • Add third-party senders with include inside that one record, and remove the ones you stop using.
  • Stay within 10 DNS-lookup terms, counting everything nested inside each include.
  • Start with ~all, move to -all once every sender is listed, and never use +all.
  • Test after every change in cPanel and with Gmail’s Show original.

Frequently asked questions

Can my domain have one SPF record for my host and another for my newsletter tool?

No. RFC 7208 forbids more than one SPF record on the same name, and two records produce a permerror, a permanent failure of the check. Merge them into one record by adding the newsletter tool's include to the record you already have.

Should my SPF record end in ~all or -all?

Use ~all while you are still finding every service that sends as you, because it asks receivers to be suspicious rather than reject outright. Move to -all once the record lists every sender, ideally with DKIM and DMARC in place too. Never use +all, which authorises every server on the internet.

Does SPF replace DKIM and DMARC?

No. SPF checks the return-path address that readers never see, and it often breaks when mail is forwarded. Your domain also needs DKIM to sign messages and DMARC to tie the result to the visible From address.

Does an SPF record cover my subdomains?

No. An SPF record only applies to the exact name it is published on, so news.example.com needs its own record if mail is sent from it. That is also useful: moving campaign mail to a subdomain takes pressure off the main domain's lookup budget.

I changed hosts and now my email goes to spam. Why?

If your old SPF record listed the previous server's IP address directly, the new server is no longer authorised to send. Update the record to include the new server, remove what you no longer use, and send a test message.

Read next

Jordan & Gulf

Does Server Location Matter? Germany, the Gulf and Speed

An honest look at what a server in Germany means for visitors in Jordan and the Gulf: what distance really adds, when it matters, how caching and a CDN reduce it, and how to measure it yourself.

Ready to start, or have a question first?

We answer on WhatsApp Saturday to Thursday, 9:00 am – 9:00 pm Amman time (GMT+3)

WhatsApp