Adding it
- Open your DNS provider. If your domain's DNS is managed by Microsoft, the Microsoft 365 admin centre adds it for you under Settings, Domains.
- Look for an existing TXT record that starts with
v=spf1. If there is one, edit it rather than adding a second. - Add or edit the TXT record on
@with the value above, then check it below.
Other tools send email too?
Add each sender's include to the same record, before the ending. With SendGrid as well, for example:
v=spf1 include:spf.protection.outlook.com include:sendgrid.net -all
Printers, scanners and on-site apps that send through your own mail server need that server's public IP as ip4: in the record.
The mistakes I see most
- Two SPF records. A permanent error: receivers ignore SPF altogether. Merge them into one.
- A record left from the old host. After a move to Microsoft 365, records still pointing at the previous provider stay around for years. Remove includes for services you no longer use.
- DKIM never switched on. Microsoft 365 signs with its own
onmicrosoft.comdomain until you turn DKIM on for yours, and that signature doesn't count for DMARC. Check it with the DKIM checker, which spots this case. - Too many lookups. Past ten DNS lookups SPF fails with a permanent error. See fixing "too many DNS lookups".
~all or -all?
Microsoft's own example ends in -all (hard fail). If you're not yet sure every sender is listed, start with ~all, publish DMARC with reports, and tighten once the reports are clean.