Microsoft 365

Microsoft 365 · Exchange Online · Gateways

Microsoft 365 + third-party gateway: fix SPF and DMARC fails with Enhanced Filtering

First published 27 October 2026 · Updated on 12 November 2026 · Verified against Microsoft Learn (Enhanced Filtering for Connectors; trusted ARC sealers) (sources listed below)

Merroway Editorial · Verified against governing standards and vendor documentation.

The fast answer

Do not add the gateway’s IPs to SPF records and do not whitelist senders one by one. The fix is two settings on the inbound connector that receives mail from the gateway: turn on Enhanced Filtering for Connectors (skip the last IP, so Exchange judges the real sender), and — if the gateway modifies messages — add it as a trusted ARC sealer. Then re-check headers. Both settings are in the Defender portal, not in DNS.

Advertisements

What you are looking at, in plain words

With a gateway in front, the mail path is: sender → gateway → Exchange Online → mailbox. Exchange’s protection sees the last hop — the gateway’s IP — and runs SPF against it. The gateway’s IP is not on the sender’s SPF record (why would it be?), so SPF fails, DMARC can fail with it, and filtering acts on a verdict about the wrong server. Enhanced Filtering tells Exchange to skip that last hop and evaluate the hop before it — the real sender. Separately, if the gateway edits messages (disclaimers, footers, link rewriting), it can break DKIM; trusted ARC sealers let Exchange trust the authentication results the gateway observed before it edited the message. You may need one of these, or both; the headers tell you which.

Symptom in headersFix
SPF fails, sender IP is your gatewayEnhanced Filtering on the gateway’s inbound connector
DKIM fails (body hash) after the gateway touched the messageTrusted ARC sealer for the gateway’s sealing domain
BothBoth, in that order

Step 0 — Prove which part is failing

  1. Confirm the timeline: did the failures start when the gateway (Mimecast, Proofpoint, Barracuda or similar) went in front of Exchange Online, and do they affect mail that previously passed? If yes, this guide fits; if mail always failed, fix SPF/DKIM/DMARC for the sender first.
  2. Open a failed message’s headers and confirm the connecting IP (or the SPF verdict’s IP) belongs to the gateway, not the original sender.
  3. In the Exchange admin centre, open Mail flow → Connectors and find the inbound connector that receives mail from the gateway. Note its name and whether Enhanced Filtering is already enabled on it.
  4. If DKIM fails with a body-hash error, look for ARC-Seal headers and note the d= value — that is the gateway’s sealing domain, needed for the ARC step.
Do not fix the wrong thing first. Stuffing the gateway’s IPs into every sender’s SPF record is not a fix: you do not control senders’ records, and it would authorise the gateway to send as anyone. Likewise, do not turn off filtering for the gateway’s IP range to “make the problem go away” — that blinds Exchange to everything the gateway forwards, good and bad.

Fix 1 — Turn on Enhanced Filtering for the gateway’s inbound connector

In the Defender portal, go to Email & Collaboration → Policies & Rules → Threat policies → Rules → Enhanced filtering, select the gateway’s inbound connector, and set IP addresses to skip to Automatically detect and skip the last IP address. Microsoft recommends first applying it to a small set of test recipients, then widening to the whole organisation once headers confirm the fix. The PowerShell equivalent is:

Set-InboundConnector -Identity "From Gateway" -EFSkipLastIP $true

Use your connector’s real name. If the gateway uses several egress IPs and skipping only the last hop is not enough, the same page lets you list the specific gateway IPs to skip — but list only the gateway’s own egress IPs, never Microsoft 365 IPs, loopback or private ranges, which Microsoft does not support here.

Fix 2 — If the gateway modifies mail, trust its ARC seal

In the Defender portal, go to Email & collaboration → Policies & rules → Threat policies → Email authentication settings → the ARC tab, and add the sealing domain from Step 0 (the d= value in the gateway’s ARC-Seal header). The PowerShell equivalent is:

Set-ArcConfig -Identity Default -ArcTrustedSealers "gateway-sealing-domain.example"

Note that this parameter replaces the whole list, so include any sealers you already trust in the same command. Only trust vendors you actually use: a trusted sealer can pass messages through your authentication checks, so every entry is a trust decision, not a formality. Allow up to 30 minutes for the change to take effect before re-testing with new messages.

Fix 3 — Re-check, then widen

Send test mail from an outside sender through the gateway to a test recipient, read the headers, and confirm SPF now evaluates against the original sender and DKIM/DMARC behave as they did before the gateway. Only then widen Enhanced Filtering from the test recipients to the whole organisation, and only then close the incident — a gateway change that is “fixed” for one sender may still be wrong for another path.

Advertisements

Prove it worked

  1. Send outside mail through the gateway to a test mailbox and confirm in headers that SPF passes (or fails, if the sender genuinely fails) against the original sender’s IP, not the gateway’s.
  2. Confirm previously junked legitimate mail now reaches the inbox for the test recipients, then for everyone once widened.
  3. Confirm the gateway still filters genuinely bad mail — a fix that lets everything through has overshot.

Still not working? Work this ladder in order

  1. Enhanced Filtering is on but SPF still shows the gateway IP. You edited the wrong connector, or the mail arrives on a different connector than the gateway’s. Trace one message’s connector and re-apply there.
  2. SPF fixed, DKIM still fails with a body-hash error. The gateway edits messages after signing. Add the trusted ARC sealer (Fix 2), or move the edit before signing if the gateway supports it.
  3. Mail from one sender still fails. That sender may genuinely fail authentication. Judge it on its own headers, not on the gateway pattern.
  4. You cannot find the connector. If mail flows straight to Exchange Online with no gateway connector, this guide does not apply — the gateway may be configured as an MX change only, and the connector setup itself is the missing piece.

Mistakes that make it worse

  • Adding gateway IPs to senders’ SPF records (you do not control them).
  • Skipping Microsoft 365 IPs, loopback or private ranges in Enhanced Filtering.
  • Trusting every ARC sealer a vendor suggests, including ones you do not use.
  • Widening Enhanced Filtering to everyone before a single test header confirms the fix.

FAQ

Why did mail work before the gateway and fail after it?

Because Exchange started seeing the gateway as the sender. SPF is an IP check, so a new last hop changes the verdict even though the original sender and their records never changed.

Is Enhanced Filtering the same as allowlisting the gateway?

No. Allowlisting skips filtering for that source. Enhanced Filtering keeps filtering but judges the real sender behind the gateway — much safer.

Do I need trusted ARC sealers if I use Enhanced Filtering?

Only if the gateway modifies messages in a way that breaks DKIM. If it passes messages untouched, Enhanced Filtering alone is enough.

Sources

Microsoft Learn — Enhanced filtering for connectors in Exchange Online (skip-last-IP, skip-list, test-then-widen) · Microsoft Learn — Configure trusted ARC sealers (ARC tab, Set-ArcConfig, d= value from ARC-Seal headers).

Verification note: record values, limits and procedure order on this page were checked against the official sources listed above on 12 November 2026.