Why does DMARC fail with a gateway in front of Microsoft 365?
DMARC fails with a gateway in front of Microsoft 365 because Exchange Online Protection checks SPF against the IP that connected to it, which is the gateway, and because gateway banners or link rewriting break the sender's DKIM signature. With neither aligned SPF nor aligned DKIM left, DMARC fails on legitimate mail. Enhanced Filtering for Connectors and trusted ARC sealers fix it.
This article covers the Microsoft 365 receiving side: what Exchange Online sees, which headers prove the cause, and which tenant settings fix it. For the general picture of how any secure email gateway touches SPF, DKIM and DMARC, including outbound relaying, read how secure email gateways affect DMARC, SPF and DKIM. For the protocol basics, start with the DMARC guide.
Key takeaways
- SPF fails inside Microsoft 365 because the connecting IP is the gateway, not the original sender (RFC 7208 checks "the IP address of the SMTP client that is emitting the mail").
- DKIM survives a gateway only if the gateway leaves the signed headers and body untouched. Banners, disclaimers, subject tags and URL rewriting usually break it.
- Enhanced Filtering for Connectors (skip listing) lets Microsoft 365 find the real source IP. Trusted ARC sealers let it reuse the gateway's original authentication results.
- When the MX record points to a gateway, Microsoft 365 does not send DMARC aggregate reports for that domain, so the receiving side is partly invisible in your reports.
- Check headers, not just reports:
Authentication-Results,ARC-Authentication-Resultsand thecompauthreason code tell you which fix applies.
What does the mail flow look like when a gateway sits in front of Microsoft 365?
When a gateway sits in front of Microsoft 365, the domain's MX record points to the gateway, the gateway filters the message, and then relays it to Exchange Online through an inbound connector. Microsoft 365 therefore receives every internet message from the gateway's IP addresses, not from the original sending server.
Direct: Sender MTA (198.51.100.10) -> Exchange Online Protection -> mailbox
Gateway: Sender MTA (198.51.100.10) -> Secure email gateway (203.0.113.20)
-> inbound connector -> Exchange Online Protection -> mailbox
Microsoft describes the effect plainly in its Enhanced Filtering for Connectors documentation: in this routing, "the message adopts the source IP of the last hop that sits in front of Microsoft 365." Everything else in this article follows from that one fact.
Is outbound mail through a gateway the same problem?
No. Outbound mail through a gateway is a different problem with a different owner. When a client's Microsoft 365 tenant relays outbound mail through a gateway, recipients see the gateway as the sender, so the client's SPF record must cover the gateway, and DKIM must be applied after any disclaimer is added. That is the sender's DNS and signing to fix.
The inbound scenario in this article is about the receiving tenant: legitimate mail from other organisations fails authentication inside Microsoft 365 because of the client's own gateway. The sender's records may be perfect. The outbound case, including where DKIM signing should happen, is covered in detail in the gateway article.
Why does SPF fail when Microsoft 365 sits behind a gateway?
SPF fails because SPF authorises IP addresses, and the only IP Microsoft 365 sees is the gateway's. The sender's SPF record lists its own mail servers, not your client's gateway, so the check against 203.0.113.20 returns fail or softfail even though the original hop from 198.51.100.10 would have passed.
RFC 7208 defines the SPF input as the MAIL FROM domain plus "the IP address of the SMTP client that is emitting the mail". There is no SPF mechanism for "the server two hops back". A typical result in Exchange Online looks like this:
Authentication-Results: spf=fail (sender IP is 203.0.113.20)
smtp.mailfrom=sender.example; dkim=fail (body hash did not verify)
header.d=sender.example; dmarc=fail action=oreject
header.from=sender.example; compauth=fail reason=000
The sender IP is value is the giveaway: if it belongs to the gateway, SPF was never evaluated against the real source. This is not a sender misconfiguration, and the fix is not to ask every sender on the internet to add your gateway to their SPF record.
When does DKIM survive the gateway, and when does it break?
DKIM survives when the gateway relays the message without changing any signed header or the body. It breaks when the gateway alters content covered by the signature: adding an external-sender banner or disclaimer, tagging the subject, rewriting URLs for click protection, or stripping or re-encoding attachments. Microsoft 365 then reports dkim=fail (body hash did not verify).
DKIM, defined in RFC 6376, signs a hash of the canonicalised body (the bh= tag) and a list of header fields (the h= tag). Any change to those breaks verification. The common causes behind a gateway:
| Gateway action | What it changes | DKIM result |
|---|---|---|
| Scan and relay, no changes | Adds only Received and trace headers | Usually passes |
| External sender banner or disclaimer | Body | Fails (body hash) |
Subject tag such as [EXTERNAL] |
Subject header (normally in h=) |
Fails (signature) |
| URL rewriting for click protection | Body | Fails (body hash) |
| Attachment removal or sanitising | Body (MIME parts) | Fails (body hash) |
Because DKIM does not depend on the IP address, a gateway that only scans and relays leaves aligned DKIM intact, and DMARC still passes on DKIM even though SPF fails. That is why the same gateway produces DMARC passes for some senders and failures for others: the failures come from messages it modified.
Why does DMARC then fail?
DMARC fails because it needs at least one aligned pass. RFC 9989 (section 5.3.5) says a message passes if one or more authenticated identifiers align with the From domain. Behind a gateway, SPF fails on the gateway IP, and if the gateway also modified the message, DKIM fails too, leaving nothing aligned.
How Microsoft 365 acts on that failure depends on the sender's policy and the tenant's anti-phishing settings. Microsoft's DMARC configuration page states that with Honor DMARC record policy turned on, a p=reject failure is rejected and stamped dmarc=fail action=oreject, and p=quarantine goes to Junk Email. Behind a gateway, that can mean legitimate mail from a well-protected sender is the mail most likely to be lost. RFC 9989 section 5.4 still leaves final handling to the receiver's local policy, which is why overrides exist.
How does composite authentication (compauth) fit in?
Composite authentication is Microsoft's single verdict that combines SPF, DKIM, DMARC and other signals, stamped as compauth= with a three-digit reason code. Microsoft says in its email authentication overview that a compauth failure "doesn't directly result in a message being blocked". The reason code is your fastest diagnostic.
The codes most relevant to gateways, from Microsoft's anti-spam message headers reference:
| compauth reason | Meaning | What it suggests behind a gateway |
|---|---|---|
000 |
Explicit fail: DMARC failed and policy is quarantine or reject | Gateway IP evaluated and DKIM broken |
001 |
Implicit fail: no records, or a weak policy | Sender has weak records; not gateway specific |
1xx |
Pass (for example 101: DKIM signed by the From domain) | DKIM survived the gateway |
130 |
ARC result from a trusted ARC sealer overrode the DMARC failure | Trusted ARC sealer is working |
905 |
DMARC not enforced due to complex routing | Microsoft detected the gateway hop and backed off |
How does Enhanced Filtering for Connectors fix it?
Enhanced Filtering for Connectors, also called skip listing, tells Exchange Online which IP addresses on an inbound connector belong to your gateway, so it skips them and evaluates the real source IP. Microsoft states that it is intended for scenarios where the MX record doesn't point to Microsoft 365, and that authentication then becomes explicit, based on the source domain's SPF, DKIM and DMARC records.
Microsoft's documentation adds that skip listing "intelligently recovers from DKIM signature failures", which helps when the gateway modifies messages but cannot ARC-seal them. You can enable it on the inbound connector in PowerShell:
# Skip the last hop (the gateway) for a pilot group first
Set-InboundConnector -Identity "From Secure Email Gateway" -EFSkipLastIP $true -EFUsers "pilot1@client.example","pilot2@client.example"
# Or list every gateway IP explicitly
Set-InboundConnector -Identity "From Secure Email Gateway" -EFSkipIPs 203.0.113.20,203.0.113.21
Points from Microsoft's guidance worth enforcing per client:
- Test on a small set of users first. In pilot mode, the feature applies only if every recipient of a message is on the list.
- After enabling it, disable mail flow rules that set SCL -1 for mail through that connector. Microsoft calls SCL -1 "an input to filtering, not a final decision".
- Confirm it works: Microsoft stamps
X-MS-Exchange-ExternalOriginalInternetSenderwhen skip listing succeeds for the recipients. - It is for services in front of Microsoft 365, not services that scan mail after it.
The step-by-step setup lives in our Enhanced Filtering for Connectors guide for MSPs.
How do trusted ARC sealers fix it?
A trusted ARC sealer lets Microsoft 365 reuse the authentication results your gateway recorded before it modified the message. The gateway validates SPF, DKIM and DMARC on arrival, seals the results with ARC, and Microsoft 365, once told to trust that sealer, can use them to override a DMARC failure caused by the gateway's own changes.
ARC is defined in RFC 8617, an Experimental RFC. Each intermediary adds an ARC-Authentication-Results, ARC-Message-Signature and ARC-Seal set with an instance number i=, and the seal carries cv=none, pass or fail. The RFC is explicit that ARC "is not a trust framework": whether to accept a sealer's results is local policy. In Microsoft 365, that decision is the trusted ARC sealer list.
Per Microsoft's trusted ARC sealer guide, you add the sealer's signing domain (the d= value in the gateway's ARC-Seal, not your client's domain) in the Defender portal under Email Authentication Settings > ARC, or in PowerShell:
Get-ArcConfig
# -ArcTrustedSealers replaces the whole list, so include existing entries
Set-ArcConfig -Identity Default -ArcTrustedSealers "gateway-vendor.example"
A working override looks like this in the message headers:
ARC-Seal: i=1; a=rsa-sha256; d=gateway-vendor.example; s=arc; cv=none; b=...
ARC-Authentication-Results: i=1; gateway-vendor.example;
spf=pass smtp.mailfrom=sender.example; dkim=pass header.d=sender.example;
dmarc=pass header.from=sender.example
...
Authentication-Results: spf=fail (sender IP is 203.0.113.20)
smtp.mailfrom=sender.example; dkim=fail (body hash did not verify)
header.d=sender.example; dmarc=fail action=none header.from=sender.example;
compauth=pass reason=130
ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=fail ...;
arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=sender.example]
dkim=[1,1,header.d=sender.example] dmarc=[1,1,header.from=sender.example])
Microsoft documents arc=pass with oda=1 as "The previous ARC sealer is trusted. The previous pass result can be used to override the current DMARC failure", and compauth=pass reason=130 as proof the override was applied. Allow up to 30 minutes for changes to take effect. Add only legitimate, required services. The ARC explainer covers the chain mechanics in depth.
Should you use Enhanced Filtering, ARC, or both?
Use trusted ARC sealing when your gateway supports it, because it preserves the original results even after the gateway changes the message. Microsoft positions Enhanced Filtering for Connectors as the option when a service that modifies messages does not support ARC. Many MSPs enable skip listing as well so SPF and IP reputation are evaluated against the real source.
How do you troubleshoot DMARC failures behind a gateway?
Troubleshoot from the headers of an affected message in the recipient's mailbox. Compare the gateway's own ARC-Authentication-Results with Microsoft's Authentication-Results: if the gateway saw a pass and Microsoft saw a fail, the gateway path caused it. Then match the symptom to the table below.
| Symptom | Header evidence | Likely cause | Fix |
|---|---|---|---|
| SPF fails for many unrelated senders | spf=fail (sender IP is <gateway IP>) |
Microsoft evaluates the gateway as source | Enable Enhanced Filtering on the inbound connector |
| DKIM fails only on modified mail | dkim=fail (body hash did not verify); banner or rewritten links visible |
Gateway modified signed content | Trusted ARC sealer; review banner and rewrite settings |
| DMARC fails, gateway saw pass | Gateway AAR dmarc=pass, Microsoft dmarc=fail |
ARC sealer not trusted | Add the ARC-Seal d= domain as a trusted ARC sealer |
| ARC present but no override | arc=fail or no oda=1 |
Broken chain, or modification after sealing | Make sure the gateway seals as the last step before delivery |
| Override working | arc=pass ... oda=1, compauth=pass reason=130 |
Expected behaviour | None; document it |
| Skip listing not applied | No X-MS-Exchange-ExternalOriginalInternetSender |
Recipient not in EFUsers, or wrong IPs |
Fix the user scope or EFSkipIPs list |
dmarc=fail action=oreject but delivered |
SCL -1 rule or allow entry | Override in place | Remove SCL -1 rules after enabling Enhanced Filtering |
For reading raw headers quickly, use the Email Header Analyzer or follow our email header triage guide. If your DMARC data shows rejections the user never noticed, see why DMARC reports say reject but the email was delivered.
Why are Microsoft's DMARC reports missing for domains behind a gateway?
Microsoft 365 only sends DMARC aggregate reports when the recipient domain's MX record points directly to Microsoft 365. Microsoft's DMARC documentation states that if internet mail is routed through a non-Microsoft service or device first, aggregate reports aren't sent, including hybrid routing through on-premises Exchange.
This cuts both ways for an MSP. As a sender, mail you send to organisations behind a gateway will not appear in Microsoft's reports for your domains, so your view of those recipients depends on whether their gateway sends reports. As the receiving tenant's administrator, you cannot use Microsoft's reports to see gateway-induced failures, which makes header checks on real messages essential.
What should an MSP check for each client with a gateway?
For each client with a gateway in front of Microsoft 365, an MSP should confirm the MX target, the inbound connector and its skip-listing settings, the trusted ARC sealer list, and any SCL -1 rules or allow entries. Then verify on a real message that compauth passes for a known good external sender. Record the result per client.
- MX record:
Resolve-DnsName client.example -Type MXordig +short MX client.example. If it points to the gateway, this article applies. - Inbound connector:
Get-InboundConnector | Format-List Name,EFSkipLastIP,EFSkipIPs,EFUsers. Note whether skip listing is on and scoped to everyone. - Gateway IPs: make sure
EFSkipIPsincludes every public IP the gateway delivers from, including intermediate hops. - ARC:
Get-ArcConfig. Check the gateway'sARC-Seald=domain is listed and the gateway seals after its last modification. - Bypass rules: list mail flow rules setting SCL -1 and Tenant Allow/Block entries. Remove broad bypasses once authentication works.
- Honor DMARC: confirm the anti-phishing policy setting so you know how
p=quarantineandp=rejectfailures are handled. - Gateway modifications: record banners, subject tags, URL rewriting and attachment handling, because these decide whether DKIM survives.
- Test message: send from an external domain with
p=rejectand aligned DKIM and read the headers. - Change record: log the configuration so a gateway migration or connector change does not silently undo it.
At portfolio scale, put this checklist into onboarding: our DMARC onboarding checklist for MSP clients and DMARC for Microsoft 365 clients cover the surrounding steps. If you also manage the client's own sending domains, DMARC AI processes DMARC aggregate reports across all client tenants and uses AI to classify sending sources, which helps separate gateway relays from unauthorised senders.
Is ARC a free pass for failed DMARC?
No. ARC only helps when the sealer is trusted, the seal validates, and the sealer recorded the original results correctly. RFC 8617 tells recipients to "treat every Sealer of the ARC Chain with suspicion", and Microsoft bases the final spoofing decision on composite authentication. Trust only the gateway you actually route through, never a sealer just because it appears in headers.
The same caution applies to the shortcuts admins reach for first: a broad SCL -1 transport rule or a domain-wide allow entry makes the symptom disappear but also lets spoofed mail through that path. Fix the evaluation (skip listing and ARC) rather than switching it off.
FAQ
Do senders need to add my gateway to their SPF record?
No. Your inbound gateway is your infrastructure, not theirs, so it does not belong in their SPF record. The SPF failure happens because Microsoft 365 evaluates your gateway's IP. Fix it on your side with Enhanced Filtering for Connectors, which lets Exchange Online skip the gateway hop and check SPF against the original sending server.
Does the gateway break DKIM on every message?
No. A gateway that only scans and relays adds trace headers but leaves the signed headers and body alone, so the sender's DKIM signature still verifies and DMARC passes on DKIM. DKIM breaks on messages the gateway modifies: banners, disclaimers, subject tags, rewritten links or removed attachments. Those messages need a trusted ARC sealer or skip listing.
What does compauth=pass reason=130 mean?
It means Microsoft 365 used the ARC result from a trusted ARC sealer to override a DMARC failure. It is the expected header once your gateway seals messages and its signing domain is on the trusted ARC sealer list. You will usually see it next to dmarc=fail and an ARC-Authentication-Results header containing arc=pass and oda=1.
Why do I get no Microsoft DMARC reports for a domain behind a gateway?
Microsoft 365 sends DMARC aggregate reports only when the recipient domain's MX record points directly to Microsoft 365. When internet mail first passes through a gateway or on-premises server, Microsoft does not send them. Any aggregate data for that receiving path must come from the gateway itself, if it supports reporting, plus header checks.
Is an SCL -1 transport rule an acceptable workaround?
Only as a temporary measure. A rule that bypasses spam filtering for everything arriving through the gateway connector hides DMARC failures, including real spoofing. Microsoft recommends disabling SCL -1 rules for that connector once Enhanced Filtering is enabled, because SCL -1 is an input to filtering, not a final decision. Fix authentication instead.
Related articles
- How secure email gateways affect DMARC, SPF and DKIM
- ARC (Authenticated Received Chain) explained
- Microsoft 365 Enhanced Filtering for Connectors
- Why DMARC reports say reject but the email was delivered
- DMARC and email forwarding: why forwarded mail fails
- Why does DMARC fail when SPF passes?
- DMARC alignment explained
Tools mentioned
- Email Header Analyzer: parse the Received chain, Authentication-Results, ARC headers and DKIM signatures
- DMARC Checker: verify the published policy
- DNS Lookup: inspect MX, SPF, DKIM and DMARC records
Author: DMARC AI editorial team Last updated: November 2026