If your SPF record is not working, emails are likely landing in spam or being rejected. This guide walks you through diagnosing and fixing the most common causes, from syntax errors to missing mechanisms. You'll need access to your domain's DNS settings (usually through your hosting or domain registrar) and a way to check your current SPF record.
What You'll Need
- Access to your domain's DNS management panel (e.g., GoDaddy, Cloudflare, Namecheap, or your web host).
- Your email service provider's SPF requirements (e.g., Google Workspace, Microsoft 365, Zoho, or your SMTP relay).
- A DNS lookup tool (like MXToolbox, Google Admin Toolbox, or a command-line tool like dig).
- Optional: a text editor to draft your SPF record before pasting it.
Step-by-Step
- Check your current SPF record. Use a DNS lookup tool to query your domain (e.g.,
dig TXT yourdomain.com). Look for a TXT record that starts withv=spf1. If there is none, you need to create one. If there are multiple SPF records, that's a problem—you'll fix that in step 4. - Identify all email senders for your domain. List every service that sends email on behalf of your domain: your main email provider, marketing tools, transactional email services (like SendGrid or Mailgun), and any SMTP relay. Each must be included in your SPF record.
- Verify the exact SPF include or IP for each sender. Check your email provider's documentation for the exact include statement or IP range. For example, Google Workspace uses
include:_spf.google.com, and Microsoft 365 usesinclude:spf.protection.outlook.com. Copy these exactly—typos are a common cause of failure. - Combine all senders into a single SPF record. Create one TXT record that starts with
v=spf1, then add each mechanism in order. For example:v=spf1 include:_spf.google.com include:spf.protection.outlook.com ip4:203.0.113.5 -all. Do not create multiple SPF records—this causes a permanent error and breaks SPF entirely. - Set the correct end tag. The last part of your SPF record must be either
-all(hard fail),~all(soft fail), or+all(never use this). For most setups,-allis recommended because it tells receiving servers to reject emails that don't match. If you're unsure, start with~allto avoid blocking legitimate email while you test. - Add the record in your DNS panel. Go to your DNS settings, add a new TXT record. In the "Name" or "Host" field, enter
@(or your bare domain, e.g.,yourdomain.com). In the "Value" or "Content" field, paste your full SPF string. Save the record. - Wait for DNS propagation. DNS changes can take anywhere from a few minutes to 48 hours. Use a DNS checker tool to see when the new record appears globally.
- Test your SPF record. Use a tool like MXToolbox's SPF lookup. It will show you if the record is valid, if there are any syntax errors, and if you've exceeded the 10-DNS-lookup limit (more on that in Common Mistakes).
- Send a test email. Send an email to a Gmail or Outlook address and check the headers. Look for
Received-SPForAuthentication-Resultsfields. They should saypassorneutral—if they sayfailorsoftfail, you need to adjust your record.
Common Mistakes
- Having multiple SPF records. This is the #1 cause of SPF not working. DNS allows multiple TXT records, but SPF only works if there is exactly one. If you have more than one, receiving servers will return a permanent error and ignore SPF.
- Exceeding the 10-DNS-lookup limit. Each
include,a,mx, orptrmechanism counts as a DNS lookup. If your record uses more than 10, SPF fails. Useip4andip6where possible to reduce lookups. - Using
+allor forgetting the end tag.+alltells receivers to accept all emails, making SPF useless. Forgetting the end tag is a syntax error. - Incorrect include syntax. Missing the colon after
include(e.g.,include_google.cominstead ofinclude:_spf.google.com) is a common typo. - Putting the record on the wrong host. The SPF record must be on the root domain (
@), not onwwwor a subdomain. If you send from a subdomain, you need a separate SPF record for that subdomain.
Tips
- Use a DNS lookup tool before and after making changes to confirm the record is live.
- Keep a copy of your SPF record in a text file for reference.
- If you use a service like Cloudflare, ensure the proxy is not interfering with TXT records (it usually doesn't, but verify).
- Combine SPF with DKIM and DMARC for better email authentication. SPF alone is not enough for modern email deliverability.
- If you're unsure about the exact include for your email provider, search their official documentation—don't rely on third-party blogs.
Troubleshooting
If your SPF still isn't working after following the steps:
- Re-check for multiple SPF records. Some DNS panels automatically add a default TXT record. Delete any extra SPF records.
- Check for syntax errors. Use an online SPF validator (like the one at dmarcian.com) to see exactly where the error is.
- Verify the include is correct. Sometimes providers change their SPF include. Check their current documentation.
- Check if your domain has a subdomain that also sends email. If you send from
mail.yourdomain.com, you need a separate SPF record for that subdomain. - Test with a different tool. If one checker says your record is fine but emails still fail, try another tool or check the raw email headers manually.
- Wait longer. DNS propagation can be slow. If you just made changes, wait 24-48 hours before assuming it's broken.
- Check if your email provider uses a dynamic IP. If you use a shared IP, an
ip4entry might not cover all senders. Use the provider's include instead.
Frequently Asked Questions
How do I know if my SPF record is working?
Use an SPF checker tool or send a test email and inspect the headers. If the Received-SPF field says pass, it's working. If it says fail or softfail, you need to adjust your record.
Can I have more than one SPF record?
No. Multiple SPF records cause a permanent error. You must combine all mechanisms into a single TXT record.
What does -all vs ~all mean?
-all tells receiving servers to reject emails that don't match SPF. ~all tells them to accept but mark as suspicious. Use -all if you're confident your record includes all legitimate senders.
How long does SPF take to update?
DNS propagation can take up to 48 hours, but it's often much faster—sometimes just a few minutes. Use a global DNS checker to see when it's live.
Why is my SPF record not working on Gmail?
Gmail is strict about SPF. Check that you have exactly one SPF record, no syntax errors, and that all your senders are included. Also ensure your end tag is -all or ~all.
Do I need SPF if I have DKIM and DMARC?
Yes. SPF, DKIM, and DMARC work together. DMARC uses SPF and DKIM to decide how to handle emails. Without SPF, DMARC may fail even if DKIM passes.