Wrinkles

Everyday skincare basics, explained plainly

SPF Record Check: How to Test and Fix Errors

· 6 min read · Ingredients Explained

To test an SPF record, use a DNS lookup tool like dig, nslookup, or an online SPF checker, and to fix errors, edit the DNS TXT record for your domain, ensuring the SPF syntax is valid and includes all authorized senders. This article explains the step-by-step process, common mistakes, and how to verify your record after changes.

What Is an SPF Record and Why It Matters

SPF (Sender Policy Framework) is a DNS TXT record that lists which mail servers are allowed to send email on behalf of your domain. When a receiving server gets a message, it checks the SPF record of the sender's domain to see if the source IP address is authorized. If not, the email may be marked as spam or rejected outright.

SPF is one of three key email authentication standards, alongside DKIM and DMARC. While SPF alone doesn't guarantee delivery, it significantly reduces the chance of your domain being used for spoofing or phishing. Without a valid SPF record, your legitimate emails may also fail authentication checks, hurting your sender reputation.

How SPF Records Work: Syntax and Mechanism

An SPF record is a single TXT string that starts with v=spf1 and contains one or more mechanisms. Common mechanisms include:

  • ip4: – allows a specific IPv4 address (e.g., ip4:192.0.2.1)
  • ip6: – allows an IPv6 address
  • include: – pulls in another domain's SPF record (e.g., include:_spf.google.com)
  • a – allows the domain's A record IP
  • mx – allows the domain's MX servers
  • all – the catch-all; must be the last mechanism (e.g., -all for hard fail, ~all for soft fail)

Example of a typical SPF record: v=spf1 ip4:203.0.113.5 include:_spf.example.com -all. The -all at the end tells receivers that any server not listed is not authorized.

How to Test Your SPF Record

Testing your SPF record involves checking what DNS returns and validating the syntax. Here are three reliable methods:

  1. Use a command-line tool: On Linux or macOS, run dig TXT yourdomain.com. On Windows, use nslookup -type=TXT yourdomain.com. Look for a TXT record that starts with v=spf1.
  2. Use an online SPF checker: Many free tools (e.g., MXToolbox, Kitterman SPF Tester) will fetch your record, parse it, and report syntax errors or warnings. They also show the final allowed IP list after expanding include: statements.
  3. Send a test email: Send a message to a Gmail or Outlook address and view the full headers. Look for the Received-SPF field – it will say pass, fail, softfail, or neutral.

If you don't have a record at all, the query returns no TXT record for SPF, and your emails will likely fail SPF checks.

Common SPF Errors and How to Fix Them

Here are the most frequent issues found during an SPF record check, along with their fixes:

  • Missing SPF record: If no TXT record exists, create one. Use a simple v=spf1 -all if you don't send email, or add the appropriate mechanisms for your mail provider.
  • Multiple SPF records: You can only have one SPF record per domain. If you see two TXT records starting with v=spf1, merge them into a single record, combining all mechanisms.
  • Syntax errors: Common mistakes include missing v=spf1, using uppercase letters (SPF is case-sensitive), or placing all before other mechanisms. Correct the syntax and re-test.
  • Too many DNS lookups: The SPF specification allows a maximum of 10 DNS lookups (including include:, a, mx mechanisms). If you exceed this, receivers will return a permerror. Reduce the number of include: statements or use ip4: directly.
  • Using +all: This allows any server to send email as your domain, which defeats the purpose. Change it to -all or ~all.
  • Incorrect IP or include: Double-check that the IP addresses or included domains are correct and active. A typo can cause legitimate emails to fail.

Step-by-Step Guide to Fix an SPF Error

Once you've identified an error, follow these steps to correct it:

  1. Log into your DNS hosting provider's control panel (e.g., Cloudflare, GoDaddy, AWS Route 53).
  2. Navigate to the DNS management section for your domain.
  3. Find the existing TXT record that contains v=spf1. If there are multiple, note them all.
  4. Delete all SPF TXT records except one. If none exist, create a new TXT record.
  5. Edit the remaining record to include all necessary mechanisms. For example, if you use Google Workspace and a third-party email service, your record might look like: v=spf1 include:_spf.google.com include:thirdparty.com -all.
  6. Save the record and wait for DNS propagation (can take from minutes to 48 hours).
  7. Re-run the SPF check using the same tools to confirm the record is valid and returns pass for your sending IPs.

SPF vs. DKIM vs. DMARC: What's the Difference?

SPF is often confused with DKIM and DMARC, but they serve different purposes. SPF verifies the sending server's IP against a list of authorized IPs. DKIM uses a digital signature to verify that the email content hasn't been altered and that it truly came from the domain. DMARC ties them together by telling receivers what to do if SPF or DKIM fails (e.g., quarantine or reject).

For robust email authentication, you should implement all three. SPF alone is insufficient because it can fail when emails are forwarded – the forwarding server's IP may not be in your SPF record. DMARC helps mitigate that by aligning the domain in the From header with the authenticated domain.

Frequently Asked Questions

How long does it take for SPF changes to take effect?

DNS propagation can take anywhere from a few minutes to 48 hours, but typically it's under an hour for most providers. You can check with a global DNS lookup tool to see when the new record appears worldwide.

Can I have multiple SPF records for subdomains?

Yes, each subdomain can have its own SPF record, but the main domain should have only one. If you send email from a subdomain, create a separate TXT record for that subdomain.

What does ~all vs -all mean?

~all is a soft fail – it marks the email as suspicious but still accepts it. -all is a hard fail – it tells receivers to reject the email. Most experts recommend starting with ~all during testing, then switching to -all once you're confident your SPF is correct.

Why does my SPF check show 'permerror'?

A 'permerror' usually means your SPF record is malformed or exceeds the 10 DNS lookup limit. Check the syntax and reduce the number of include: statements.

Do I need SPF if I use a third-party email service?

Yes, even if you use Gmail, Outlook, or a marketing platform, you should still have an SPF record that includes their sending servers. Most providers give you the exact include: string to add.

Can SPF break my email if I make a mistake?

Yes, a misconfigured SPF record can cause legitimate emails to be rejected or marked as spam. Always test after changes and use ~all initially to avoid hard failures.

In this article
  1. What Is an SPF Record and Why It Matters
  2. How SPF Records Work: Syntax and Mechanism
  3. How to Test Your SPF Record
  4. Common SPF Errors and How to Fix Them
  5. Step-by-Step Guide to Fix an SPF Error
  6. SPF vs. DKIM vs. DMARC: What's the Difference?
  7. Frequently Asked Questions