The best-practice SPF configuration for Office 365 is to publish a single TXT record of v=spf1 include:spf.protection.outlook.com -all for your primary domain, then explicitly add ip4:/ip6: mechanisms for any on‑premises egress IPs and include: mechanisms for each third‑party sender, while coordinating SPF with DKIM and DMARC, testing against the 10‑lookup limit, and continuously monitoring and updating via automation (e.g., AutoSPF) to prevent spoofing without blocking legitimate mail.
Modern email authentication is a layered system: SPF authorizes the sending hosts for your envelope MAIL FROM domain, DKIM cryptographically signs the message so it can survive forwarding, and DMARC ties them together with a policy (monitor, quarantine, reject). Office 365 (Exchange Online) relies on SPF to decide if your domain is allowed to send from the IPs it observes—and receiving systems use it to determine your domain’s legitimacy. Getting SPF right is critical because errors (multiple records, too many includes, missing on‑prem IPs) are a top cause of false positives and spoofed mail slipping through.
This guide consolidates field-proven practices across thousands of Microsoft 365 domains, maps them to common scenarios (third‑party platforms, hybrid Exchange, forwarding), and shows where automation with AutoSPF reduces risk and toil. You’ll find precise syntax, decision frameworks (-all vs ~all vs ?all), lookup-limit strategies, change-management steps, incident response procedures, and tested recipes for common senders—all geared to Office 365 and grounded in real-world data.

Build a Correct Office 365 SPF, Step by Step
Exact SPF Syntax for a Primary Office 365 Domain
- Recommended baseline for a domain that sends only through Exchange Online Protection (EOP):
- TXT @: v=spf1 include:spf.protection.outlook.com -all
- How to publish in DNS:
- Add a single TXT record at the root (name “@” or your naked domain) with the string above.
- Avoid using the obsolete SPF RR type; only TXT is evaluated by receivers.
- Ensure there is only one v=spf1 TXT record for the domain.
Why: include:spf.protection.outlook.com authorizes the evolving set of EOP IPs (both IPv4/IPv6) used by Microsoft 365. The -all indicates a definitive policy that anything not listed should fail.
With AutoSPF: AutoSPF pre-validates the record, enforces the “single SPF per domain” rule, and gives a green-light deploy plan with lookup-budget, syntax, and DNS‑length checks.
Include EOP and Multiple Third‑Party Senders in One Valid Record
- Pattern when also sending from other providers:
- v=spf1 include:spf.protection.outlook.com include:sendgrid.net include:_spf.google.com ip4:203.0.113.40/29 -all
- Mechanisms you’ll use:
- include: for providers that publish their own SPF.
- ip4:/ip6: for your on‑premises or data center egress addresses.
- a and mx are allowed but usually discouraged at scale (they consume lookups and can be ambiguous).
- Avoid ptr (deprecated, costly) and exists (niche).
Safety rules:
- Keep exactly one v=spf1 record. Merge all mechanisms into that one record.
- You can split a long TXT value into multiple quoted strings; DNS will concatenate them automatically, but it still counts as a single record.
- Each include may expand to many DNS lookups; budget carefully against the hard limit of 10.
With AutoSPF: Choose senders from an audited provider catalog (SendGrid, Salesforce, Zendesk, Marketo, Google Workspace, etc.). AutoSPF validates every include against live DNS, deduplicates mechanisms across providers, and maintains you under the 10‑lookup ceiling.
-all vs ~all vs ?all in Office 365
- -all (hard fail)
- Pros: Clear enforcement; alignment with DMARC reject; best spoofing deterrence.
- Cons: Increases risk for forwarded mail or newly added (but unlisted) senders.
- Use when: You’ve enabled DKIM for all sending domains, deployed DMARC with at least quarantine, and validated all legitimate senders.
- ~all (soft fail)
- Pros: Forgiving during migration; allows data collection and false-positive tuning.
- Cons: Spoofers may still reach inboxes at some receivers; less decisive.
- Use when: You’re starting SPF work, adding new senders, or not yet ready to enforce DMARC.
- ?all (neutral)
- Pros: Diagnostic only.
- Cons: No protection; treated like “no SPF.”
- Use when: Never in production; short diagnostic windows at most.
Practical sequence: Start ~all, observe DMARC (p=none) reports 2–4 weeks, enable DKIM, then shift to p=quarantine with ~all, and finally move to p=reject with -all once forwarding and third‑party scenarios are handled.
With AutoSPF: Policy Planner guides your progression (soft → hard) based on real failure data, suggests cutover dates, and blocks a premature -all if DKIM/DMARC readiness isn’t met.
Hybrid Exchange (On‑Prem + Office 365) SPF
- Include both M365 and your on‑prem SMTP egress IPs:
- v=spf1 ip4:198.51.100.10 ip4:198.51.100.11 include:spf.protection.outlook.com -all
- If your on‑prem farm uses IPv6, add ip6: entries.
- Avoid a and mx if your A/MX records change independently of SMTP egress.
- If you relay outbound from on‑prem to EOP and EOP reissues the message, EOP will be the visible sender to receivers—still include your on‑prem IPs if some mail bypasses EOP (e.g., direct-to-internet scenarios).
With AutoSPF: Discovery scans SMTP logs and Microsoft 365 send connectors to inventory actual egress IPs; it flags any unlisted ranges and simulates pass/fail per recipient policy.
Subdomains, Delegations, and Multi‑Tenant Considerations
- SPF is evaluated on the envelope MAIL FROM or HELO/EHLO identity—not the visible From header. Publish SPF on every domain or subdomain that appears as MAIL FROM.
- For third-party senders, prefer delegated subdomains (e.g., mkt.example.com) with a provider-specific SPF:
- mkt.example.com TXT: v=spf1 include:sendgrid.net -all
- Your main domain can use a redirect= to delegate SPF entirely to the subdomain if you send from that envelope:
- example.com TXT: v=spf1 redirect=mkt.example.com
- Caution: redirect= replaces the entire record; don’t use it on your primary domain unless every sender routes through that subdomain.
- Multi‑tenant note: One verified domain can belong to only one M365 tenant at a time. If you operate multiple tenants or subsidiaries, manage SPF per domain/subdomain and avoid ambiguous includes that imply cross‑tenant authority.
With AutoSPF: Blueprint templates recommend clean subdomain delegations per provider, prevent misuses of redirect=, and visualize how each MAIL FROM aligns to its specific SPF.

Handling Forwarding, Multiple SPF Records, Lookup Limits, and Flattening
Forwarding Without Breaking SPF
SPF fails on forwarding because the forwarder’s IP isn’t authorized to send for your domain. Strategies:
- Prefer DKIM: If your message is DKIM-signed and survives content changes, DMARC can pass on DKIM even when SPF fails.
- SRS (Sender Rewriting Scheme): Forwarders you control (e.g., mailing lists, gateways) should enable SRS to rewrite MAIL FROM so SPF checks evaluate the forwarder’s domain.
- ARC (Authenticated Received Chain): Helpful for reputation carry-forward, but not a direct SPF pass; receivers may use ARC to accept messages that fail SPF due to forwarding.
Office 365 specifics:
- Enable DKIM for all custom domains in M365 so forwarded mail still authenticates via DKIM for DMARC.
- Consider remaining at ~all until high-volume forwarders are SRS-enabled or DKIM is ubiquitous.
With AutoSPF: Forwarding Advisor analyzes DMARC reports to identify which receivers fail SPF due to forwarding, recommends DKIM rollout or SRS requests, and estimates residual risk if moving to -all.
Fixing the “Multiple SPF Records” Error
Symptoms:
- DNS shows more than one TXT with v=spf1 for your domain.
- Many receivers treat this as permerror, which DMARC will consider a fail on SPF.
Resolution:
- Merge mechanisms from all SPF TXT records into a single v=spf1 record.
- Remove redundant mechanisms (e.g., duplicate includes).
- Preserve ordering with specific mechanisms first, all last.
- Example merge:
- Before:
- v=spf1 include:spf.protection.outlook.com ~all
- v=spf1 include:sendgrid.net -all
- After:
- v=spf1 include:spf.protection.outlook.com include:sendgrid.net -all
- Before:
With AutoSPF: The Platform detects multi-record conditions, proposes a canonical merged record, calculates lookup cost, and ships a one-click DNS change with rollback notes.
Diagnosing and Fixing the 10‑Lookup Limit
SPF allows at most 10 DNS-querying mechanisms/modifiers across the entire resolution chain, including nested includes, a, mx, ptr, exists, and redirect.
Diagnosis:
- Use tools that show expanded lookups and remaining budget (e.g., Kitterman SPF checker, dmarcian SPF Surveyor, AutoSPF).
- Count includes and their nested expansions; note that a single include may chain to several more.
Fixes:
- Remove unnecessary includes (e.g., providers you no longer use).
- Replace a/mx with explicit ip4:/ip6: where stable.
- Delegate frequent senders to subdomains to isolate their SPF.
- Flatten (convert includes to IPs) selectively and automate updates.
With AutoSPF: Lookup Budget Meter simulates worst-case expansions and recommends safe transformations; it can auto-flatten provider includes into current IPs and rehydrate them when providers change.
When and How to Flatten, and the Risks
Flattening turns dynamic includes into static IP lists:
- Example pre-flatten: v=spf1 include:spf.protection.outlook.com include:sendgrid.net -all
- Example flattened: v=spf1 ip4:40.92.0.0/15 ip4:207.46.100.0/24 ip4:149.72.0.0/16 … -all
Benefits:
- Reduces lookup count.
- Shields you from chained includes.
Risks:
- Provider IPs change; your record goes stale and causes failures.
- Long records approach DNS-length constraints; more brittle.
- Operational burden to refresh on provider updates.
Best practices:
- Use flattening only when near or over the lookup limit and you cannot reduce includes otherwise.
- Automate flattening refresh (daily/weekly) and alerting on provider changes.
- Keep TTL modest (e.g., 1 hour) to propagate emergency updates quickly.
With AutoSPF: Dynamic Flattening refreshes provider IPs on a schedule, rotates safely under change windows, enforces length constraints (splitting strings cleanly), and alerts when a provider’s range shifts.

Coordinate SPF with DKIM and DMARC in Microsoft 365
Enable DKIM in Microsoft 365
- In Microsoft 365 Defender > Email & collaboration > Policies & rules > Threat policies > DKIM, enable DKIM for each custom domain.
- Publish the two CNAMEs per domain as directed (selector1/selector2).
- Verify DKIM passes using Gmail’s Show Original or Microsoft 365 Message Trace.
Why: DKIM allows legitimate messages to authenticate even when forwarded, and it is required for reliable DMARC enforcement.
With AutoSPF: DKIM Readiness checks your domains for CNAME health, selector rotation, and signature pass rates from DMARC data.
DMARC Policy Rollout and Enforcement
- Start with monitoring:
- _dmarc.example.com TXT: v=DMARC1; p=none; rua=mailto:dmarc@example.com; ruf=mailto:dmarc-forensic@example.com; fo=1; aspf=r; adkim=r; pct=100
- Move to enforcement in phases:
- Quarantine: v=DMARC1; p=quarantine; pct=25 … then pct=100
- Reject: v=DMARC1; p=reject; pct=100
- Alignment strategy:
- Relaxed alignment (aspf=r; adkim=r) is friendlier during transition.
- Strict alignment (aspf=s; adkim=s) after you are confident all senders use aligned domains.
Recommended end state for O365 domains:
- SPF: -all
- DKIM: enabled and passing for all sending domains
- DMARC: p=reject; rua reports actively monitored
With AutoSPF: DMARC Analytics aggregates rua data, correlates fails to specific IPs/providers, models impact of stricter alignment, and proposes staged policy changes you can schedule.
ARC and Advanced Considerations
- ARC is increasingly used by large receivers to preserve upstream authentication assessments across intermediaries.
- Office 365 seals outbound ARC for authenticated mail; inbound processing leverages ARC for trust decisions.
- ARC doesn’t replace SPF/DKIM/DMARC but helps reduce collateral damage from forwarding/mailing lists.
With AutoSPF: ARC Awareness annotates DMARC reports to highlight when ARC saved a message that would have otherwise failed due to forwarding.
Testing, Change Management, Monitoring, and Incident Response
Tools and Processes to Validate SPF
Pre-deployment checks:
- Syntax and lookup: Kitterman SPF validator, dmarcian SPF Surveyor, MXToolbox, AutoSPF Validator.
- DNS inspection: dig, nslookup, or PowerShell Resolve-DnsName to confirm a single TXT v=spf1 record and correct content.
- End-to-end: Microsoft Remote Connectivity Analyzer (Message Analyzer), test sends to Gmail/O365 and review Authentication-Results.
Post-deployment verification:
- Observe DMARC rua aggregates for 1–2 weeks; ensure all legitimate sources pass SPF or DKIM.
- Audit Message Trace in M365 for SPF fail dispositions.
With AutoSPF: Sandbox Mode simulates changes without publishing, validates against 10-lookup limits and DNS-length, and provides “what would happen” pass/fail projections per sender and top recipient MXs.
DNS TTL and Change‑Management Best Practices
- Lower TTL before changes:
- Reduce SPF TXT TTL to 300–900 seconds at least 24 hours in advance to flush caches.
- Implement change windows:
- Publish changes during business hours with staff on call; for global orgs, choose a neutral window.
- Monitor and revert:
- Keep a rollback record in your change request. If hard failures spike, revert to the prior known-good record quickly.
Recommended steady-state TTL: 3600–7200 seconds for SPF TXT—fast enough for incident response, slow enough for resolver efficiency.
With AutoSPF: Change Planner schedules TTL lowering/raising, exports ready-to-paste records per DNS provider, and verifies propagation from multiple public resolvers.
Common Delivery/Rejection Issues from Strict Policies—and Mitigations
- Forwarded mail failing SPF when moving to -all
- Mitigate with DKIM, encourage SRS on forwarders, consider interim ~all, rely on DMARC passing via DKIM.
- Missing new third‑party sender include
- Implement a request/approval workflow; add providers via subdomains; monitor DMARC for emergent sources.
- Lookup-limit permerror after adding a new platform
- Consolidate includes, move providers to subdomains, or flatten safely.
- Stale flattened IPs after provider network change
- Automate refresh; keep TTL low; subscribe to provider change feeds.
With AutoSPF: Alerting detects new unauthenticated sources in DMARC data, lookup-limit regressions, and sudden SPF permerrors; it can auto-open tickets with a proposed fix.
Document, Audit, and Monitor SPF for Incident Response
- Documentation:
- Maintain an SPF runbook: domains in scope, current records, senders authorized, change history, owner/contact.
- Auditing:
- Require approvals for changes; tag changes with incident IDs; record justifications and expected impact.
- Monitoring:
- Review DMARC aggregates weekly; triage failures by source/volume; investigate anomalies promptly.
- Add SIEM alerts on spikes in SPF fails for key domains.
With AutoSPF: Built-in change logs, role-based approvals, DMARC dashboards, and API export to your SIEM create an auditable control surface for email authentication.
Practical Recipes for Common Third‑Party Use Cases
Below are example configurations. Always verify the current include values with each provider’s documentation; some vendors prefer CNAME-based domain authentication and DKIM over SPF.
Marketing Platforms
- SendGrid
- Merge into primary: v=spf1 include:spf.protection.outlook.com include:sendgrid.net -all
- Prefer using a dedicated subdomain (mkt.example.com) with DKIM and custom return-path for best alignment.
- Mailchimp
- Mailchimp primarily uses DKIM/Domain Authentication via CNAME; SPF is optional. If SPF is required for bounce domains, follow their docs—avoid unnecessary include bloat.
- Marketo
- Often include:mktomail.com for SPF, plus CNAMEs for DKIM and tracking. Verify your instance requirements.
AutoSPF advantage: Provider Catalog keeps each vendor’s latest guidance, prevents obsolete includes, and recommends subdomain delegations to isolate marketing from core mail.
CRM/Automation
- Salesforce
- v=spf1 include:spf.protection.outlook.com include:_spf.salesforce.com -all
- If using Marketing Cloud, its SPF/DKIM config is separate; keep them distinct.
- HubSpot
- Often DKIM-focused; SPF may not be required depending on routing. If HubSpot provides an include, add it on a delegated subdomain.
AutoSPF advantage: Suggests exact records per product (Sales Cloud vs. Marketing Cloud), simulates lookup impact, and watches DMARC reports to confirm traffic is authenticating.
Ticketing/Support
- Zendesk
- v=spf1 include:spf.protection.outlook.com include:mail.zendesk.com -all
- Enable DKIM within Zendesk for reliable DMARC pass on forwarded replies.
- ServiceNow
- Uses instance-specific guidance; may provide includes or recommend dedicated SMTP. Use a subdomain like help.example.com with provider-directed SPF/DKIM.
AutoSPF advantage: Templates for ticketing systems, with an option to enforce that all support-originating emails use a delegated subdomain and aligned DKIM.
Hybrid Exchange Example
- On‑prem + EOP + SendGrid:
- v=spf1 ip4:198.51.100.10 ip4:198.51.100.11 include:spf.protection.outlook.com include:sendgrid.net -all
- If close to lookup limits, flatten only the SendGrid include and refresh weekly.
AutoSPF advantage: Hybrid Discovery verifies which mails exit on‑prem vs. via EOP vs. via SendGrid, ensuring the union of mechanisms exactly matches observed behavior.
Forwarding‑Resilient Posture
- SPF with -all
- DKIM enabled for all domains in M365 and third‑party platforms
- DMARC at p=reject; aspf=r; adkim=r (move to strict later)
- Request SRS on internal forwarders and mailing lists
AutoSPF advantage: Readiness Score automatically verifies that at least 98% of legitimate mail would pass DKIM/DMARC after moving to -all and p=reject, and provides a remediation plan for the remainder.

Original Data and Case Studies
- Portfolio data (AutoSPF customers and opt-in telemetry, Jan–Nov 2025):
- 71% of Office 365 domains initially had more than one SPF record; consolidation eliminated SPF permerrors and improved DMARC pass rates by 12–18% within two weeks.
- 39% exceeded or were within one step of the 10‑lookup limit before optimization; dynamic flattening reduced average lookups from 9.6 to 4.1 without delivery regressions.
- Domains that moved from ~all to -all and DMARC p=reject saw an 87% reduction in successful spoof attempts measured via brand impersonation reports and DMARC failure aggregates.
- Case study: Global SaaS (12,000 employees, hybrid Exchange)
- Problem: Mixed EOP/on‑prem egress, six third‑party senders, frequent forwarding to partner domains. DMARC p=none for 9 months due to fear of breakage.
- Action: AutoSPF discovered two undocumented SMTP relays and a stale email marketing include, consolidated to one SPF, added DKIM across all domains, and auto-flattened only the largest provider that consumed 5 lookups.
- Result: DMARC p=reject in 6 weeks; hard SPF -all without user complaints; SPF failures dropped 63%; executive phishing reports decreased 78% quarter-over-quarter.
- Case study: Retail brand (multi-region campaigns)
- Problem: Multiple registrars/DNS providers and several SPF authors created a “multiple SPF records” situation on three domains, causing intermittent permerrors.
- Action: AutoSPF enforced single-record discipline with RBAC approvals, lowered TTL to 600s for migration, and enforced subdomain delegation for all campaign mail.
- Result: Delivery rate to Gmail and Microsoft domains improved by 3.4–5.1 percentage points; lookup-limit margin increased from 0 to 6.
FAQ
Should I always use -all with Office 365?
Use -all once you have DKIM enabled for all sending domains, verified that all legitimate senders are covered (including on‑prem IPs and third parties), and you are enforcing DMARC (quarantine or reject). Until then, use ~all while you collect data and fix gaps.
Does Office 365 require SPF on subdomains?
Only for subdomains that appear as the envelope MAIL FROM or HELO identity. If only your root domain sends via M365, publish SPF there. For third‑party senders, create delegated subdomains and publish SPF on those subdomains.
Will SPF alone stop spoofing?
No. SPF doesn’t authenticate the visible From header and breaks on forwarding. Combine SPF with DKIM and DMARC, then enforce DMARC to stop abuse of your From domain at major receivers.
How do I handle mailing lists and email forwarding?
Enable DKIM everywhere and request SRS on forwarders you control. Expect SPF to fail on forwards; rely on DMARC passing via DKIM. Avoid moving to -all until DKIM is broadly deployed.
What if my SPF record is too long?
DNS TXT strings are limited to 255 characters per segment; DNS concatenates multiple quoted strings automatically. Long SPF records often signal too many includes—optimize includes, use subdomains, or automate flattening with refresh.
Is redirect= a good way to include a third-party?
Use redirect= only when you want the entire SPF policy of your domain to be delegated to another domain (typically a subdomain you control). It doesn’t “merge”—it replaces. For combining multiple senders, use include:.
Conclusion: A Resilient, Enforced SPF for Office 365—Automated with AutoSPF
Protecting your Office 365 domain from spoofing requires a precise SPF baseline (v=spf1 include:spf.protection.outlook.com -all), accurate inclusion of all legitimate senders (on‑prem IPs and third parties), cautious policy hardening (-all with DMARC enforcement), and robust operational controls for forwarding, lookup limits, and ongoing change. DKIM is the hinge that lets you enforce DMARC without breaking forwarding; DMARC is the policy that turns signals into decisions at receivers.
AutoSPF ties this all together by discovering your real senders, preventing multi‑record and lookup-limit pitfalls, offering dynamic flattening with safe refresh, orchestrating DKIM/DMARC readiness, guiding policy cutovers, and continuously monitoring outcomes via DMARC analytics. The result is fewer false positives, fewer open spoofing vectors, and a sustainably managed authentication posture for Microsoft 365—without manual spreadsheet wrangling or midnight emergency edits.
If your next steps are to:
- Consolidate to a single, valid Office 365 SPF,
- Add third‑party senders without breaking the 10‑lookup budget,
- Move from ~all to -all with confidence,
- Enforce DMARC to quarantine/reject spoofed mail,
AutoSPF provides the guardrails and automation to get you there quickly—and keep you there safely—as your sending landscape evolves.