
An SPF record is one line of text in your domain’s DNS that lists the servers allowed to send email for that domain. For a business on Microsoft 365 alone, the whole record can be v=spf1 include:spf.protection.outlook.com -all. On Google Workspace alone, Google gives v=spf1 include:_spf.google.com ~all.
Setting it up takes three decisions, not just copying a line: which services actually send as your domain, how strict the ending should be, and whether all those services fit inside SPF’s limit of 10 DNS lookups. Get those right and the record rarely needs touching. Get them wrong and mail from a forgotten invoicing tool or copier starts failing.
You add the record at your DNS host, which is usually where you bought the domain. Neither Microsoft 365 nor Google Workspace manages SPF for your custom domain; Microsoft states there’s no admin portal or PowerShell cmdlet for it.
The short version
- List everything that sends mail as your domain: mailboxes, website, CRM, invoicing, copiers, newsletters.
- Look up your current record with
nslookup -type=txt yourdomain.comso you edit it instead of adding a second one. - Build one line starting
v=spf1, with aninclude:orip4:for each sender, ending in-allor~all. - Publish it as a TXT record with host
@at your DNS host, replacing any old SPF value. - Count lookups:
include,a,mx,existsandredirecteach cost one, and the total must stay at 10 or fewer. - Send a test to an outside mailbox and confirm the headers show
spf=pass.
Step 1: find every service that sends as your domain
Most SPF failures we see trace back to this step being skipped. SPF only vouches for the senders you list, and with a strict ending, every sender you forget is told to fail.
| Sender | How it usually goes in SPF | Notes |
|---|---|---|
| Microsoft 365 mailboxes | include:spf.protection.outlook.com | Government cloud tenants (GCC High, DoD) use include:spf.protection.office365.us instead |
| Google Workspace mailboxes | include:_spf.google.com | Google recommends ending this record with ~all |
| A copier, scanner or server at the office with a static public IP | ip4: plus that address | Costs no lookups; only works if the IP never changes. Sending through Microsoft 365 or Gmail is usually better |
| Website contact forms on your web host | Whatever the host documents, often an include: or ip4: | Better: send form mail through your mail provider or a sending service |
| CRM, newsletter, ticketing or invoicing tools | Only what the vendor’s domain authentication page tells you | Many send from their own bounce domain and authenticate yours with DKIM, so they need no SPF entry at all |
To find senders you’ve forgotten, ask whoever pays the software bills which tools email customers, check your website’s mail settings, and look at the DNS records a previous IT person added. A DMARC record with reports, covered in our DMARC setup guide, lists every server that sent as your domain, which is the most reliable inventory there is.
Step 2: build the record
An SPF record is a single string read left to right. These are the parts you’ll actually use:
| Part | What it does | Counts as a lookup? |
|---|---|---|
v=spf1 | Marks the record as SPF; must come first | No |
include:domain | Authorizes everything in another domain’s SPF record (your provider’s) | Yes, plus any lookups nested inside it |
ip4: / ip6: | Authorizes a specific address or range | No |
a / mx | Authorizes the servers your domain’s A or MX records point to | Yes |
-all | Hard fail: anything not listed isn’t authorized | No |
~all | Soft fail: anything not listed probably isn’t authorized; accept but mark it | No |
?all | Neutral: no opinion. For testing only | No |
Examples for example.com
- Microsoft 365 only:
v=spf1 include:spf.protection.outlook.com -all - Google Workspace only:
v=spf1 include:_spf.google.com ~all - Both during a migration (Google’s own example):
v=spf1 include:_spf.google.com include:spf.protection.outlook.com ~all - Microsoft 365 plus a scanner on a fixed office IP:
v=spf1 ip4:203.0.113.10 include:spf.protection.outlook.com -all - A domain you own but never send from:
v=spf1 -all
That last one matters more than people think. Spammers like borrowing domains that have no SPF at all, so give every parked domain a record that says nobody sends for it. Note also that a and mx are rarely needed with hosted email; leaving them out saves lookups.
Step 3: publish it at your DNS host
- Back up first. Export or screenshot your current DNS zone. If mail stops, you can put the old values back in a minute.
- Find any existing SPF record. Look through the TXT records for one starting
v=spf1. If there is one, edit it. A domain or subdomain may only have one; Microsoft says two make SPF returnpermerror, which fails every message. - Create or edit a TXT record. Use
@as the host (some DNS hosts want the name field left blank for the root domain). For a subdomain such as news.example.com, the host isnews. - Paste the value. Some hosts want it wrapped in quotation marks; follow your host’s instructions, then check what it actually saved.
- Set the TTL. Microsoft recommends at least 3600 seconds (one hour) on SPF records.
- Don’t use the old SPF record type. If your DNS host offers a record type called SPF, ignore it. RFC 7208 retired that type, so SPF must be published as TXT.
Small typing mistakes break the whole record. Microsoft lists these as common errors:
- A trailing period after the domain:
include:spf.protection.outlook.com. - An equals sign instead of a colon:
include=spf.protection.outlook.com - A space after the colon:
include: spf.protection.outlook.com
An include: pointing at a domain with no SPF record also causes a permanent error, which can happen when a vendor you’ve stopped using retires its domain.
-all or ~all: which ending to use
Microsoft and Google give different advice here, and both are reasonable. Microsoft recommends -all for Microsoft 365 domains. Google recommends ~all for Workspace.
| Your situation | Ending | Why |
|---|---|---|
| Microsoft 365, DKIM on, every sender listed | -all | Microsoft notes DMARC largely ignores an SPF soft fail on a message without DKIM, so -all lets DMARC act on unsigned spoofed mail |
| Google Workspace, following Google’s setup | ~all | Google’s recommended value; DMARC does the enforcing |
| You’re not sure you’ve found every sender | ~all for now | A forgotten service gets marked rather than rejected while DMARC reports show what you missed |
| Domain that never sends mail | -all on its own | Nothing legitimate can fail |
| Testing a brand-new setup | ?all briefly, then change it | Neutral gives no protection, so don’t leave it |
Either way, SPF on its own doesn’t decide delivery for most receivers anymore. The protection comes from SPF plus DKIM plus DMARC together.
Rather have a technician sort it out?
If you’re not sure which services send as your domain or how to merge them into one SPF record, a technician can connect remotely with your permission and set it up with you. A GoProIT technician can connect remotely, with your permission, and fix it while you watch. $59 per fix, Mon–Fri 8am–8pm ET.
Stay under the 10-lookup limit
Receivers stop evaluating SPF after 10 DNS lookups and return a permanent error, so a record that looks fine can quietly fail. Microsoft says the bounce may read that the message exceeded the hop count or required too many lookups.
What counts: every include:, a, mx, exists and redirect, plus every lookup nested inside an include. Your provider’s include alone can use several. ip4:, ip6: and all are free. Because receivers stop once they find a match, a record over the limit can pass for your staff mail and fail for the vendor listed last, which makes the problem look random.
Ways to get back under 10
- Remove dead entries. Old web hosts, a newsletter tool you cancelled, an
mxyou never needed. - Move bulk senders to a subdomain. Microsoft recommends services you don’t control send from something like news.example.com. Each subdomain gets its own record and its own 10 lookups, and their reputation stays separate from your staff mail.
- Swap an include for addresses when a vendor publishes a small, stable IP list. You then have to watch for changes.
- Flatten carefully, if at all. Flattening replaces includes with the IPs behind them. Microsoft says never to do this for Microsoft 365, whose sending addresses change often, and to review flattened entries at least quarterly.
Test the record
Check what the world sees, not what your DNS control panel shows.
- In Command Prompt:
nslookup -type=txt example.com. You should see exactly one line startingv=spf1. - In PowerShell:
Resolve-DnsName -Name example.com -Type TXTshows the same. - Use a free SPF checker that counts lookups; most DNS testing sites have one.
Then send a real message from each service you listed to an outside mailbox and read the headers. In the Authentication-Results line you want spf=pass with smtp.mailfrom= showing the domain that was checked. If that domain belongs to the vendor rather than you, SPF passed for them, not you, and your domain needs DKIM from that service to pass DMARC.
Google says SPF can take up to 48 hours to start working after a change, so a fail in the first few minutes doesn’t mean the record is wrong. If messages are already bouncing, see the 550 5.7.26 fix; if they arrive but go to junk, see emails going to spam.
Admin notes and when to get help
- The onmicrosoft.com domain already has SPF that Microsoft maintains. You can’t edit it, and you don’t need to.
- Each subdomain needs its own record if it sends mail. The record on example.com doesn’t cover anything below it.
- During a move between Microsoft 365 and Google, list both providers until the old one stops sending, then remove it.
- Keep a note of why each entry is there and who asked for it. Without that note, the next person to edit DNS can’t tell a live sender from a leftover.
Get help when your record is already near 10 lookups, when nobody knows what some entries are for, or when you can’t get into the DNS host. If you’d rather not do it yourself, building or cleaning up one domain’s SPF record is a typical $59 remote fix. Getting SPF, DKIM and DMARC set up together is part of our email security and 2FA setup, and ongoing DNS and mailbox care sits under Microsoft 365 management or Google Workspace management.
Common questions
Can I have two SPF records for one domain?
No. A domain or subdomain can publish only one TXT record beginning v=spf1. With two, receivers can’t tell which to use, and SPF returns a permanent error for all your mail. When a new service asks you to add an SPF record, add its include or IP to your existing record instead of creating a new one.
What is the SPF record for Microsoft 365?
For most commercial Microsoft 365 tenants it is v=spf1 include:spf.protection.outlook.com -all, published as a TXT record on your custom domain. Government Community Cloud High and DoD tenants use include:spf.protection.office365.us instead. If other services also send as your domain, add their entries before the -all at the end.
Does SPF stop people spoofing my email address?
Only partly. SPF checks the hidden envelope sender used between servers, not the From address people see, so a spammer can pass SPF on their own domain while showing your name in From. DMARC closes that gap by requiring SPF or DKIM to pass for the same domain as the visible From address.
Do I need an SPF record if I don’t send email from my domain?
Yes, and it’s the simplest one there is: v=spf1 -all. It tells receivers no server is allowed to send for that domain, which makes it harder for spammers to use. Microsoft recommends this for parked domains, alongside a DMARC record with a reject policy.
Why does my SPF check pass but DMARC still fails?
SPF passed for a different domain than the one in your From address. Many sending services use their own bounce domain, so SPF passes for them, not you. DMARC needs the domain that passed to match your From domain. Set up DKIM with your domain at that service, or have it use a return-path on your domain if it offers one.
How do I check how many DNS lookups my SPF record uses?
Use an online SPF checker that expands every include and reports the total; doing it by hand means looking up each include and the includes inside it. Remember that ip4 and ip6 entries are free while include, a, mx, exists and redirect each cost one. Recheck after a vendor changes its own record, because its nested lookups count against you.