Authenticate email with Microsoft 365 (SPF and DKIM)

Short answer: If your domain’s mailboxes are in Microsoft 365, you publish one SPF record that includes spf.protection.outlook.com, plus two DKIM CNAME records whose values the Defender portal shows you, and then you switch DKIM signing on for the domain. This applies to mail sent through Microsoft 365. A store that sends through an SMTP plugin or a sending service needs that service’s records too.

Reviewed

Symptom

Your store or your staff send mail from an address at your own domain (for example orders@example.com) and your mailboxes are in Microsoft 365. A checker, a bounce or a mailbox provider says SPF or DKIM is missing or failing, or you were told to “authenticate your domain”.

Why it happens

Microsoft 365 is the usual home of a business mailbox, but it does not publish records for your own domain. Microsoft says it creates the DNS records only for the onmicrosoft.com domain. For a custom domain, you create the records at your domain registrar or DNS host, because Microsoft 365 has no screen or command for managing SPF in your DNS.

Two kinds of record are involved:

  • SPF (Sender Policy Framework) is a TXT record, a text entry in your domain’s DNS. It lists the services that may send mail for your domain.
  • DKIM (DomainKeys Identified Mail) is a signature added to each message. Receivers check it against a public key published in your DNS.

Start by checking who actually sends your store’s email. Mail that leaves through Microsoft 365 needs the records on this page. Mail that leaves through an SMTP plugin’s service or a sending service is signed and authorized by that service, so it needs that service’s records. See the guide to authenticating email by mail service to find the right page.

Fix

Part 1: SPF

  1. Look up your current SPF record. Your domain may only have one SPF record. Microsoft says several SPF records on one domain cause a permerror, which means receivers cannot evaluate it. If you already have one, edit it instead of adding a second. The SPF record guide shows how to find it.
  2. Add the Microsoft 365 include. Microsoft says most Microsoft 365 organizations need include:spf.protection.outlook.com in the SPF record. If Microsoft 365 is the only service that sends mail from your domain, the record on Microsoft’s page is:

“text v=spf1 include:spf.protection.outlook.com -all “

Create it as a TXT record at your DNS host, for the host name of your domain (many DNS hosts show this as @).

  1. If other services also send as your domain, add each service’s own include: value inside the same record, before the ending. Microsoft’s own example is v=spf1 ip4:192.168.0.10 include:spf.protection.outlook.com -all, for a company that also has a mail server at that address. Use the values your other service documents.
  2. Choose the ending, -all or ~all. The ending tells receivers what to do with mail from sources you did not list. This is the one place where Microsoft’s page and the plugin differ:
    • Microsoft’s page recommends -all (hard fail) for Microsoft 365 domains, because it also recommends DKIM and DMARC. It says a DMARC policy is effectively ignored for an SPF ~all failure if the message also has no DKIM signature, so -all lets DMARC act on such messages.
    • Microsoft describes ~all (soft fail) as “accept but mark”, and says what happens depends on the receiver.
    • The plugin’s starter SPF record uses ~all for the providers that have an include value, as Microsoft 365 does. It is only a generic starting record that the plugin suggests when you have none.

Use the ending that fits your setup. If you are not sure that every service that sends as your domain is listed, ~all is the softer choice, and you can switch to -all after you have listed them all and set up DKIM. We follow Microsoft’s page that -all is its recommendation for a domain with DKIM and DMARC in place.

  1. Mind the common typing mistakes. Microsoft’s page lists these as wrong: a dot after the name (include:spf.protection.outlook.com.), an equals sign instead of a colon (include=), and a space after the colon (include: spf...).
  2. Government and China-operated clouds use other values. Microsoft’s SPF page gives a different include for Microsoft 365 GCC High and DoD, and for Microsoft 365 operated by 21Vianet, and says GCC uses the same value as the standard one. Take the value from Microsoft’s SPF page, not from this guide.
  3. Keep the lookup limit in mind. An SPF record may cause at most 10 DNS lookups, and every include: counts at least one. Microsoft’s page says not to flatten (replace with IP addresses) the Microsoft 365 include, because its sending addresses change often. If you go over the limit, see SPF too many DNS lookups.
  4. Use a time to live of about an hour. Microsoft recommends a TTL (the time DNS answers are kept) of at least 3600 seconds on SPF records.

Part 2: DKIM

For DKIM, Microsoft 365 uses two CNAME records. A CNAME is a DNS entry that points one name at another name. The names you create are the same for every organization. The values they point to are specific to your domain.

  1. Add the domain to Microsoft 365 first. Microsoft says you can only use a custom domain for DKIM signing after it has been added to Microsoft 365.
  2. Open the Defender portal. Microsoft’s page gives this path: go to security.microsoft.com, then Email & collaboration, Policies & rules, Threat policies, Email authentication settings, and open the DKIM tab. Screens change, so if yours differs, follow Microsoft’s DKIM page.
  3. Get your two values. Microsoft’s steps: try the toggle for your domain, which gives an error message that contains the values. The status then shows CnameMissing. Click the row (not the toggle) and read the Publish CNAMEs section of the details panel, where you can also copy the values. Microsoft also describes a PowerShell command, Get-DkimSigningConfig, that shows Selector1CNAME and Selector2CNAME for a domain.
  4. Create the two CNAME records at your DNS host. The host names, as Microsoft states them, are:

“text selector1._domainkey selector2._domainkey “

The value of each record is the value from step 3. Do not make it up. Microsoft says the values printed in its article are for illustration only. Microsoft also says domains added to Microsoft 365 after May 2025 use a newer format, and domains and initial domains that existed before keep the old one, so your values can look different from examples you find elsewhere.

  1. Watch the host name. Some DNS hosts add your domain to the name for you. If yours does, enter only selector1._domainkey. If you also typed the domain, you get a name such as selector1._domainkey.example.com.example.com, which is wrong.
  2. Wait a few minutes. Microsoft says it takes a few minutes, possibly longer, to detect the new records.
  3. Turn on signing. Go back to the details panel of the domain on the DKIM tab and select Sign messages for this domain with DKIM signatures. Microsoft says a message then tells you it may take several minutes to synchronize. Signing starts only after this step, so publishing the records is not enough.
  4. Do this for each subdomain you send from. Microsoft says each subdomain you use to send mail from Microsoft 365 needs its own DKIM setup and its own SPF record.

If you use only the onmicrosoft.com address for mail, Microsoft says you need to do nothing: its SPF record already exists, and its mail is signed automatically.

Part 3: DMARC

SPF and DKIM are the two checks that DMARC builds on. Microsoft says SPF alone is not enough and recommends DKIM and DMARC too. The steps are in DMARC for beginners.

Check it worked

  1. Use the free checker. Type your domain. For SPF, it should show your record and the Microsoft 365 include.
  2. DKIM in the checker. The checker tries 14 fixed selector names, and selector1 and selector2 are two of them. It asks DNS for TXT records, and DNS normally follows a CNAME to the TXT record at the end of it. We ran such a lookup with PHP on 2026-11-16 against selector1._domainkey.github.com, a public name that is a CNAME to a Microsoft-hosted key. It returned the key. So the checker can see Microsoft’s CNAME-based keys, but we tested one name only, and a result can depend on your DNS resolver. If the DKIM line says “Not checked”, that is not a failure: look the records up yourself, as in the next point.
  3. Look the records up yourself. On a computer with a command line, run dig +short CNAME selector1._domainkey.example.com (use your own domain). You should see the value that the Defender portal showed you. Run it again for selector2.
  4. Check the status in the Defender portal. Microsoft says that when the records are found and signing is on, the status reads Signing DKIM signatures for this domain.
  5. Send a real test. A published record does not prove that mail is signed. Send an email from the address to a mailbox at another large provider, open the message source (“show original”), and look for dkim=pass and spf=pass. Sending to your own Microsoft 365 mailbox does not prove it for other receivers.

If it still fails

  • SPF says permerror. You may have two SPF records, a typing mistake from step 5 of Part 1, or too many lookups.
  • Status stays at CnameMissing. The records are not visible yet, or the names are wrong. Check the host name (step 5 of Part 2) and wait.
  • Mail still fails after both are set up. The mail may leave through another service. Check Yahoo and Outlook rejecting your emails and Avoid WooCommerce emails going to spam.

How the plugin helps

Email Health Check & Log for WooCommerce can tell when your site sends mail through Microsoft 365. It does this by reading the mailer or SMTP host in the settings of three SMTP plugins. When SPF or DKIM fails, it shows the include spf.protection.outlook.com, a starter SPF record, and a short text for the two CNAME records, with a link to Microsoft’s pages. It does not read your Microsoft 365 account, publish records or turn signing on. 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.