Wrinkles

Everyday skincare basics, explained plainly

Right SPF for Emails? A Practical Guide

· 7 min read · Ingredients Explained

Yes, you likely have the right SPF for your emails if your domain's SPF record includes all legitimate sending sources, does not exceed the 10-DNS-lookup limit, and uses a hard fail policy (-all) — but many domains don't, and getting it wrong can cause your emails to land in spam or be rejected outright.

What SPF Actually Does

SPF (Sender Policy Framework) is an email authentication method that lets a domain owner publish a list of IP addresses and servers that are allowed to send email on that domain's behalf. When a receiving mail server gets a message, it checks the envelope sender (the return-path address, not the From header you see) against the published SPF record in DNS. If the sending IP is listed, the message passes SPF; if not, it fails.

SPF is one of three mainstream authentication standards, alongside DKIM (DomainKeys Identified Mail) and DMARC (Domain-based Message Authentication, Reporting, and Conformance). SPF alone does not protect your domain from spoofing, but it is a required building block. DMARC uses SPF and DKIM results to decide what to do with unauthenticated mail, so a broken SPF record can undermine your entire email security posture.

How to Check Your Current SPF Record

Your SPF record lives as a TXT record in your domain's DNS. You can look it up with a simple command or an online tool. To check manually, open a terminal and type:

nslookup -type=TXT yourdomain.com

Or use dig on Linux/macOS: dig TXT yourdomain.com. Look for a line that starts with v=spf1. If there is no such record, you have no SPF — and that is a problem, because many receiving servers treat missing SPF as a negative signal. If there are multiple TXT records that start with v=spf1, you have a more serious issue: SPF records cannot be merged, and having more than one usually causes a permanent error (a 'permerror') that makes all your mail fail SPF checks.

Why Your SPF Might Be Wrong

Even if you have an SPF record, it may not be right. The most common mistakes are:

  • Missing senders: You added your web server but forgot your email marketing platform, CRM, or transactional email service. Any service that sends as your domain must be listed.
  • Too many DNS lookups: SPF allows a maximum of 10 DNS lookups per check. Each include:, a:, mx:, or ptr: mechanism can count as a lookup. Exceeding 10 causes a permanent error, and your mail fails SPF even if the sending IP is legitimate.
  • Using ~all (soft fail) when you want hard fail: Soft fail tells receivers the message is suspicious but not definitively forged. Hard fail (-all) says the message is definitely not authorized. For most domains, hard fail is recommended because it gives DMARC clearer signals.
  • Including ptr: unnecessarily: The ptr mechanism is slow, deprecated, and counts against your lookup limit. Avoid it.

How to Build the Right SPF Record

To create a correct SPF record, follow these steps:

  1. List every legitimate source that sends email from your domain. This includes your own mail server, your web server (if it sends password resets), and any third-party services (e.g., Google Workspace, Microsoft 365, Mailchimp, SendGrid).
  2. Write the record starting with v=spf1. Use include: for each third-party service (they provide the exact syntax, often like include:_spf.google.com).
  3. Add a and mx if your own servers send mail. Usually mx is enough for your own mail server.
  4. Count your DNS lookups. Each include: counts as one, plus a, mx, and ptr each count as one. Keep the total under 10.
  5. End with -all (hard fail) unless you have a specific reason to use ~all.

Example of a simple record for a domain using Google Workspace and a transactional email service:

v=spf1 include:_spf.google.com include:spf.sendgrid.net ~all

This record has two includes, so it uses two lookups — well within the limit. The ~all is a soft fail, which is acceptable during testing, but you should move to -all once you confirm all legitimate senders are listed.

Common Problems and How to Fix Them

If your SPF is failing, you will see errors in your email delivery reports or DMARC aggregate reports. The most frequent issues are:

  • SPF permerror: This usually means you have multiple SPF records or too many lookups. Fix by consolidating to one record and reducing includes.
  • SPF fail for a service you use: The service's IP is not in your record. Add the correct include: or IP range. Check the service's documentation for the exact syntax.
  • SPF passes but DMARC fails: DMARC requires alignment: the domain in the From header must match the domain used in SPF (or DKIM). If you send from a subdomain or a different domain, SPF can pass but DMARC still fails. Use DKIM to achieve alignment.

A common misconception is that SPF alone stops spoofing. It does not. An attacker can forge the From header to look like your domain, and SPF will not catch it because SPF only checks the envelope sender. That is why DMARC is necessary — it tells receivers what to do when SPF and DKIM both fail. Without DMARC, a failed SPF might just mean the email is marked as spam, but the attacker's email still gets delivered to some inboxes.

SPF vs. DKIM vs. DMARC

These three standards work together, and understanding the difference helps you see if your SPF is right:

  • SPF verifies the sending server is authorized. It uses the envelope sender.
  • DKIM adds a digital signature to the email headers. The signature is verified against a public key in DNS. DKIM does not care about the sending IP; it cares about the signature being valid and the domain in the signature matching the From domain.
  • DMARC tells receivers what to do if both SPF and DKIM fail. It also requires alignment — the domain in the From header must match the domain used in SPF or DKIM.

For optimal deliverability, you need all three. SPF alone is not enough, but it is the foundation. If your SPF is broken, DKIM and DMARC cannot fully compensate.

How Often Should You Review SPF?

SPF is not a set-and-forget setting. Review it whenever you:

  • Add a new email service or marketing platform.
  • Change your mail server or hosting provider.
  • Start sending from a subdomain (e.g., news.yourdomain.com) — that subdomain needs its own SPF record.
  • Receive DMARC reports showing SPF failures for a legitimate source.

Most experts recommend checking SPF at least quarterly, but the real trigger is any change to your email infrastructure. Also, if you use a subdomain for sending (like mail.yourdomain.com), remember that SPF records are per-domain. A record on your root domain does not automatically apply to subdomains — each subdomain that sends mail needs its own record.

Frequently Asked Questions

Can I have multiple SPF records?

No. You should have exactly one SPF record per domain. Multiple records cause a permanent error, and receivers will treat all your mail as failing SPF. If you see more than one, delete the duplicates and merge them into a single record.

What does 'v=spf1' mean?

It is the version identifier that tells parsers this is an SPF record. Every SPF record must start with v=spf1 — otherwise it is ignored. If you see a TXT record without that prefix, it is not an SPF record.

Is SPF enough to stop phishing?

No. SPF only verifies the sending server, not the From header. Attackers can still spoof your domain in the From line, and SPF will not catch it. You need DMARC to instruct receivers to reject or quarantine messages that fail authentication.

What is the difference between ~all and -all?

~all means soft fail — the message is not authorized, but the receiver should accept it with suspicion. -all means hard fail — the message is definitively not authorized and should be rejected. Use -all for most domains, but start with ~all if you are still adding legitimate senders.

How do I know if my SPF is working?

Send a test email to a Gmail or Outlook address and view the full headers. Look for spf=pass or spf=fail. You can also use online SPF validation tools that check your DNS record and simulate a lookup. DMARC reports, if you have DMARC set up, will show SPF pass/fail rates for all your senders.

In this article
  1. What SPF Actually Does
  2. How to Check Your Current SPF Record
  3. Why Your SPF Might Be Wrong
  4. How to Build the Right SPF Record
  5. Common Problems and How to Fix Them
  6. SPF vs. DKIM vs. DMARC
  7. How Often Should You Review SPF?
  8. Frequently Asked Questions