Exchange OnlineHow-to

Enhanced Filtering for Connectors: a third-party email gateway in front of Exchange Online

When MX points to a non-Microsoft gateway, Exchange Online sees the gateway as the sender. Lock the inbound connector, turn on skip listing and prove it works in the headers.

Put a non-Microsoft filtering service or appliance in front of Exchange Online and every inbound message seems to come from the gateway's IP addresses. SPF results stop meaning anything, DMARC fails on messages the gateway changed, and spoof detection either fires on legitimate mail or gets bypassed completely. In this post I'll show how to lock Exchange Online to the gateway, turn on Enhanced Filtering for Connectors (also called skip listing) and prove in the message headers that it works.

How this guide is organized: How it works → Prerequisites → Step-by-step → Verify → Tips & gotchasFlow diagram of the article's sections in reading order: 1. How it works. 2. Prerequisites. 3. Step-by-step (4 steps: Accept inbound mail only from the gateway; Turn on Enhanced Filtering for a pilot group; Remove the SCL -1 bypass rule; Trust the gateway's ARC seal, if it has one). 4. Verify. 5. Tips & gotchas. Toolbox: Authentication-Results, Set-ArcConfig, File › Properties, Settings › Domains, ARC-Seal.1How it works2Prerequisites3Step-by-step4Verify5Tips & gotchas1Accept inbound mail onlyfrom the gateway2Turn on EnhancedFiltering for a pilot group3Remove the SCL -1bypass rule4Trust the gateway's ARCseal, if it has oneTOOLBOXAuthentication-ResultsSet-ArcConfigFile › PropertiesSettings › DomainsARC-SealHow this guide is organized: How it works → Prerequisites → Step-by-step → Verify → Tips & gotchasFlow diagram of the article's sections in reading order: 1. How it works. 2. Prerequisites. 3. Step-by-step (4 steps: Accept inbound mail only from the gateway; Turn on Enhanced Filtering for a pilot group; Remove the SCL -1 bypass rule; Trust the gateway's ARC seal, if it has one). 4. Verify. 5. Tips & gotchas. Toolbox: Authentication-Results, Set-ArcConfig, File › Properties, Settings › Domains, ARC-Seal.1How it works2Prerequisites3Step-by-step1Accept inbound mail only from the gateway2Turn on Enhanced Filtering for a pilot group3Remove the SCL -1 bypass rule4Trust the gateway's ARC seal, if it has one4Verify5Tips & gotchasTOOLBOXAuthentication-ResultsSet-ArcConfigFile › PropertiesSettings › DomainsARC-Seal
At a glance: how this guide is organized · 4 steps · 5 key settings and tools

How it works#

How Enhanced Filtering sees past a third-party gatewayInternet: External sender. Mail gateway: Third-party gateway. Exchange Online: Partner inbound connector, Enhanced Filtering, SPF, DKIM and DMARC checks, Recipient mailbox. Connections: 1. External sender → Third-party gateway: SMTP to the MX host. 2. Third-party gateway → Partner inbound connector: Only the gateway is accepted. 3. Partner inbound connector → Enhanced Filtering. 4. Enhanced Filtering → SPF, DKIM and DMARC checks. 5. SPF, DKIM and DMARC checks → Recipient mailbox.INTERNETExternal senderThe original IP address anddomainMAIL GATEWAYThird-party gatewayMX record points here; mayadd bannersEXCHANGE ONLINEPartner inboundconnectorRestricted to the gateway'scertificate or IPsEnhanced FilteringSkips the last IP or thelisted IPsSPF, DKIM and DMARCchecksRun against the originalsourceRecipient mailboxHeader shows the truesource address12345CONNECTIONS1External sender → Third-party gateway: SMTP to the MX host2Third-party gateway → Partner inbound connector: Only the gateway is accepted3Partner inbound connector → Enhanced Filtering4Enhanced Filtering → SPF, DKIM and DMARC checks5SPF, DKIM and DMARC checks → Recipient mailboxHow Enhanced Filtering sees past a third-party gatewayInternet: External sender. Mail gateway: Third-party gateway. Exchange Online: Partner inbound connector, Enhanced Filtering, SPF, DKIM and DMARC checks, Recipient mailbox. Connections: 1. External sender → Third-party gateway: SMTP to the MX host. 2. Third-party gateway → Partner inbound connector: Only the gateway is accepted. 3. Partner inbound connector → Enhanced Filtering. 4. Enhanced Filtering → SPF, DKIM and DMARC checks. 5. SPF, DKIM and DMARC checks → Recipient mailbox.INTERNETExternal senderThe original IP address and domainMAIL GATEWAYThird-party gatewayMX record points here; may add bannersEXCHANGE ONLINEPartner inbound connectorRestricted to the gateway's certificate or IPsEnhanced FilteringSkips the last IP or the listed IPsSPF, DKIM and DMARC checksRun against the original sourceRecipient mailboxHeader shows the true source addressCONNECTIONS1External sender → Third-party gateway: SMTP to theMX host2Third-party gateway → Partner inbound connector:Only the gateway is accepted3Partner inbound connector → Enhanced Filtering4Enhanced Filtering → SPF, DKIM and DMARC checks5SPF, DKIM and DMARC checks → Recipient mailbox
Figure 1 · Architecture How Enhanced Filtering sees past a third-party gateway. The MX record sends mail to the gateway. A restricted Partner connector accepts only the gateway, and Enhanced Filtering skips its IPs so checks run against the real source.

SMTP only shows the receiving server the IP address of the last hop. When your MX record points to a gateway, that last hop is always the gateway, so Exchange Online Protection checks SPF against the gateway instead of the real sender. If the gateway adds a banner or rewrites links, the DKIM signature breaks too, and DMARC fails with it.

Enhanced Filtering tells Exchange Online which IP addresses on an inbound connector to skip. It then evaluates the source in front of them. Microsoft says this preserves the original IP address and sender, recovers from DKIM failures caused by modification and enables explicit SPF, DKIM and DMARC checks. Two headers show it at work:

HeaderStamped when
X-MS-Exchange-SkipListedInternetSenderSkip listing is enabled on the connector, whether or not the recipient is in scope
X-MS-Exchange-ExternalOriginalInternetSenderSkip listing succeeded and the recipient matched the scope; the value contains the true source address

The feature is meant for routes where the MX record doesn't point to Microsoft 365: an inbound gateway, or a hybrid setup where internet mail enters through Exchange Server first. It isn't meant for services that scan mail after Microsoft 365; routing scanned mail out and back breaks the chain of trust.

Prerequisites#

  • Organization Management in Exchange Online, or the Exchange Administrator role in Microsoft Entra ID.
  • Your domains added and verified in Microsoft 365, with the MX record pointing to the gateway.
  • The gateway's public sending IP addresses, or the name on its TLS certificate, from the vendor's documentation. Include any intermediate hops with public IPs.
  • An SPF record that still lists only Microsoft 365 (include:spf.protection.outlook.com), unless your outbound mail also goes through the gateway. See SPF, DKIM and DMARC for your Microsoft 365 custom domain.

Step-by-step#

1. Accept inbound mail only from the gateway#

Microsoft recommends a Partner inbound connector that identifies the gateway by certificate (preferred) or by IP address, with the matching restriction turned on. After that, Exchange Online rejects messages sent straight to your tenant that try to get around the gateway:

PowerShell
Connect-ExchangeOnline

# Certificate-based (preferred)
New-InboundConnector -Name "From mail gateway" -ConnectorType Partner -SenderDomains * `
    -RequireTls $true -TlsSenderCertificateName *.gateway.example -RestrictDomainsToCertificate $true

# Or IP-based
New-InboundConnector -Name "From mail gateway" -ConnectorType Partner -SenderDomains * `
    -SenderIpAddresses 203.0.113.0/24,198.51.100.10 -RestrictDomainsToIPAddresses $true

The restriction parameters work only on Partner connectors. If an OnPremises connector already uses the same certificate or IPs, create the Partner connector anyway. Microsoft says the two can coexist.

2. Turn on Enhanced Filtering for a pilot group#

In the Microsoft Defender portal, go to Email & collaboration › Policies & rules › Threat policies › Enhanced filtering (in the Rules section) and select the connector. Under IP addresses to skip, choose one of these:

  • Automatically detect and skip the last IP address, when the gateway is the only hop in front of Microsoft 365.
  • Skip these IP addresses that are associated with the connector, when there are several hops. List every public IP of the systems that handle your mail before Microsoft 365.

Under Apply to these users, start with Apply to a small set of users. In PowerShell:

PowerShell
# Pilot: skip the last hop for three recipients
Set-InboundConnector -Identity "From mail gateway" -EFSkipLastIP $true `
    -EFUsers "michelle@contoso.com","laura@contoso.com","julia@contoso.com"

# Multiple hops: skip a list of IPs instead
Set-InboundConnector -Identity "From mail gateway" -EFSkipLastIP $false -EFSkipIPs 203.0.113.0/24,198.51.100.10

# After the pilot: apply to all recipients
Set-InboundConnector -Identity "From mail gateway" -EFUsers $null

Pilot scoping is literal. List every proxy address of each test user, and remember that a message with any recipient outside the list gets normal filtering for all of its recipients. When internet mail passes through Exchange Server on-premises first, specify the MailUser's target address (for example michelle@contoso.mail.onmicrosoft.com).

3. Remove the SCL -1 bypass rule#

Gateway setups often include a mail flow rule that sets the spam confidence level (SCL) to -1 for mail from the gateway. Once Enhanced Filtering is on, Microsoft says to disable it, except during a Defender for Office 365 evaluation or while phasing in a defense-in-depth configuration. A bypass is risky because gateway providers often share IP addresses among many customers, so spoofed and phishing mail from those IPs would skip filtering too.

4. Trust the gateway's ARC seal, if it has one#

If the gateway modifies messages and supports ARC, go to Email & collaboration › Policies & rules › Threat policies › Email authentication settings › ARC and add its sealing domain. The domain must match the d= value in the ARC-Seal and ARC-Message-Signature headers. In PowerShell, Set-ArcConfig -Identity Default -ArcTrustedSealers gateway.example replaces the whole list, so include any existing sealers. If the gateway modifies messages without ARC, review the spoof detections and add allow entries for legitimate spoofed senders. My Tenant Allow/Block List guide shows how.

Verify#

  1. Send a test from an external mailbox to a pilot user and open the message headers (in Outlook, File › Properties, or paste them into the Message Header Analyzer).
  2. Good looks like: X-MS-Exchange-ExternalOriginalInternetSender is present and contains the external sender's real IP, not the gateway's. Authentication-Results evaluates SPF against that original source, and DMARC and compauth pass for a properly authenticated sender.
  3. Only X-MS-Exchange-SkipListedInternetSender is present? Then skip listing is enabled, but the recipient is out of scope. Check -EFUsers and the proxy addresses.
  4. From a host that isn't the gateway, send a message straight to the MX value Microsoft 365 shows for your domain (Settings › Domains in the Microsoft 365 admin center). It should be rejected.
  5. Watch the Threat protection status report in the Defender portal.
PowerShell
Get-InboundConnector "From mail gateway" |
    Format-List ConnectorType, RestrictDomainsToCertificate, RestrictDomainsToIPAddresses, EFSkipLastIP, EFSkipIPs, EFUsers

Tips & gotchas#

  • Don't skip what you don't own. Microsoft 365 IP addresses aren't supported. Private (RFC 1918) and loopback addresses are skipped automatically and can't be added. IPv6 entries work only in PowerShell. Configure NAT so mail servers use public IPs.
  • Hybrid with centralized mail transport. Adding your Exchange servers is supported only for linear routes (internet › on-premises › Microsoft 365). It isn't supported when mail goes from Microsoft 365 to on-premises and back, because the returning mail is scanned again and can be marked as spam.
  • Gateway relays through Exchange Server? Microsoft says to enable Enhanced Filtering on the OnPremises inbound connector as well.
  • For the on-premises version of this design, see Email gateway in front of Exchange Server.

References#

Written and checked against current Microsoft Learn documentation. Test changes with a pilot group before rolling them out to everyone, and if an admin center path has moved since, search for the setting name instead.

Spotted a mistake, or did this fix work differently for you? Email me or message me on LinkedIn — corrections are credited in the article.

Written by

Omer Eltayeb

Intune Subject Matter Expert in Cairo, Egypt, former Microsoft Cloud Solutions Architect, Microsoft Certified Trainer and Microsoft Innovative Educator Expert (2024–26) and Microsoft Elevate Educator Expert (2026–27). I share practical, step-by-step guides, study plans, scripts and toolkits for Microsoft Intune, Configuration Manager, Microsoft Entra ID, Microsoft Defender, Exchange and Microsoft 365 with the community.

Microsoft Certified Trainer (MCT) 2026Microsoft Innovative Educator Expert 2025–2026Microsoft Elevate Educator Expert 2026–2027ISC2 Certified Information Systems Security Professional (CISSP)Microsoft 365 Certified: Enterprise Administrator Expert (MS-102)