How to set up an SPF record

Write one SPF record that lists every service sending as your domain, without breaking the rules receivers apply.

An SPF record is a TXT record on your domain that lists the servers allowed to send mail for it. Receivers compare the server that delivered a message with that list. A typical record:

example.com.  TXT  "v=spf1 include:_spf.google.com include:sendgrid.net ip4:203.0.113.25 ~all"

Step by step

  1. List every service that sends mail with your domain as envelope sender: your mailbox provider, your website or webshop, invoicing, CRM, helpdesk, scanners. Forgetting one is the most common mistake.
  2. Look up the SPF value for each. Providers document an include: (like include:spf.protection.outlook.com for Microsoft 365). For your own servers use ip4: or ip6:.
  3. Combine them into one record starting with v=spf1 and ending with ~all or -all. See which ending to use.
  4. Publish it as a TXT record on the domain itself (the "@" or empty name in most DNS panels). Replace the old record; never add a second one.

Rules receivers enforce

  • One record per domain. Two records make SPF fail for everything.
  • At most 10 DNS lookups. Every include, a, mx, exists and redirect counts, including the ones inside included records. See too many DNS lookups.
  • End with all. Without it, unlisted servers get a neutral result, which protects nothing. Anything after all is ignored.
  • Don't use ptr. It is deprecated, slow, and some receivers ignore it.
  • redirect= only works without all. If the record has both, the redirect is ignored.

Only mail from subdomains?

SPF is checked for the domain in the envelope sender (Return-Path), not the visible From address. Many email platforms use their own bounce domain, or a subdomain of yours such as bounce.example.com. In that case the SPF record belongs on that subdomain, and you don't need their include in your main record at all. For DMARC, DKIM is often what makes their mail pass.