WooCommerce SPF record: how to add or fix it

Short answer: each domain name that sends mail needs exactly one SPF record. It is a TXT record at your domain itself, and it lists the services that send your store’s email. Get the value from your mail service, add it to the one record you have (never create a second), then check it.

Reviewed

Symptom

You see one of these:

  • A checker or a plugin says “No SPF record was found.”
  • A checker says “Multiple SPF records were found.”
  • A mail service asks you to “add its SPF record” and you are not sure how, or you already have one.
  • Order emails land in spam, and SPF is one of the things to rule out. See WooCommerce emails not sending or going to spam.

Why it happens

SPF (Sender Policy Framework) is a public list, kept in your domain’s DNS (the public address book of your domain), of the servers and services allowed to send email as your domain. A receiving mail server reads the list and compares it to the server that sent the message.

The list is a single text record. RFC 7208 says SPF records are published as DNS TXT records (section 3.1), and that a domain name must not have more than one record that would be selected for the check (section 3.2). If it does, the result is a permerror, a permanent error: SPF does not pass (section 4.5). Microsoft’s documentation says the same: only one SPF record is allowed per domain.

This is why a second record is the most common mistake. Each mail service says “add this record,” a store owner does, and now there are two. The fix is to put both services into one record.

Fix

  1. Find out which services send your store’s email. Typical senders are your mailbox provider (for example Google Workspace or Microsoft 365), a transactional email service that your site connects to, and a newsletter service. If you are not sure, look at the SMTP or mail plugin settings on your site and at your mail services’ dashboards. Do not publish a record until you know.
  2. Get the value each service wants, from that service. Open the service’s own help page about SPF or domain authentication and copy the value it shows. Do not guess or copy a value from a forum: the right text depends on the service. Some services do not ask for any SPF entry on your main domain, because they use their own return-path records (a separate technical address that carries the SPF check). Their help page tells you which case you are in. Two examples that are documented by the providers:
    • Google Workspace (Gmail) only: v=spf1 include:_spf.google.com ~all, from Google’s SPF page.
    • Microsoft 365 only: v=spf1 include:spf.protection.outlook.com -all, from Microsoft’s SPF page. That value is for the standard Microsoft 365 cloud. The page lists other values for government and China-operated clouds.
  3. Look at what is already published. In a terminal, run dig +short TXT example.com (use your domain), or open the DNS settings at your DNS host (often your registrar or web host). Find any TXT record that starts with v=spf1.
  4. If there is no SPF record, add one. Create a TXT record. The name (also called host) is your domain itself, which many DNS screens want as @. Google’s page says to enter @ for the root domain. The value is the text from step 2, in this shape: v=spf1 include:<service value> ~all. Copy the value exactly: no extra spaces, no quotes unless your DNS host adds them for you.
  5. If there is already one, edit it. Do not add a second. Keep the existing record and add the new include: value before the final ~all or -all. For example, a store that sends through Google Workspace and through a second service that tells you to use include:mail.example.net ends up with one record: v=spf1 include:_spf.google.com include:mail.example.net ~all. Here mail.example.net is a made-up name; use the value your service gives you. Microsoft’s page shows the same pattern: one record with several include: values.
  6. If there are two or more, merge them. Make one record that holds every include: from all of them, with a single ~all or -all at the end. Then delete the extra records.
  7. Pick the ending. The ending says what to do with mail from senders you did not list.
    • ~all is a “softfail”. RFC 7208 calls this a weak statement that the sender is probably not authorized (section 2.6.5). Google’s page recommends ~all.
    • -all is a “fail”: a clear statement that senders not listed are not authorized. Microsoft’s page recommends -all for Microsoft 365 domains that also use DKIM and DMARC.
    • If you are unsure, use the ending the provider’s page shows, and use -all only when you are certain the list is complete. A forgotten sender will fail with -all.
    • Never end with +all or a bare all. It allows anyone to send as your domain. The free checker marks it as a fail.
  8. Keep it within 10 lookups. An SPF record may cause at most 10 DNS lookups in total, and every include: counts, including the ones inside the services’ own records. If you add many services, read SPF too many DNS lookups.

Check it worked

  1. Wait. DNS changes are not instant. Google’s page says it can take up to 48 hours for SPF to start working. Many changes show up much sooner.
  2. Open the free checker, type your domain (for example example.com) and read the SPF result. It looks up the TXT records on exactly the name you type, so use the same domain you send from.
  3. Read the label next to SPF:
    • Pass: one SPF record was found, it names at least one sender, and the checker found no problem. It is not a promise of delivery. It only says the record looks right. The checker also tells you which well-known services it recognizes in the record.
    • Warning: the record exists but something needs a look. Examples: it is only v=spf1 -all (that says no server may send, right for a domain that sends no email); it ends in ?all; it has no all ending; it uses 9 or 10 of the 10 lookups; or an included record could not be followed.
    • Fail: no record, more than one record, a record that lists no sender, a record that ends in +all, a record that needs more than 10 lookups, or an include that has no valid SPF record of its own.
    • Not checked: the DNS lookup failed or took too long, or the domain is a public mailbox domain such as gmail.com, where nobody can publish records. Try again in a few minutes.
  4. A “no record” result can also mean the DNS servers did not answer. If you just added the record, wait and check again.
  5. Send a test email from your store to a mailbox you control, open the message headers and look for spf=pass. The checker cannot see message headers, so this is the proof that your real mail passes.

SPF is one of three checks. DKIM (a signature on each message) and DMARC (the policy that ties them together) matter too. See DMARC for beginners.

How the plugin helps

Email Health Check & Log for WooCommerce checks the SPF record of the domain in your From address from the WordPress admin. It reports a missing record, more than one record, a record that authorizes no sender, and a record that does not seem to include the mail service your site sends through. For the failing cases it can show a copy-and-paste record and a link to the mail service’s own setup page where the plugin knows one (a list of common services is built in). It does not count DNS lookups, so use the lookup guide for that. Get the plugin on WordPress.org.

Check your own domain

Type your domain into the free checker to see whether your SPF, DKIM and DMARC records are in place. Or install the free plugin, which checks the basics from inside your dashboard.