7 August 2026 Updated: 25 October 2026 12 min read

Common Causes of Mail Loops and How to Fix Them

How to systematically identify and fix SMTP mail loops in Exchange Online, hybrid environments, and upstream mail gateways using NDRs, headers, Message Trace, recipient objects, and connectors.

A mail loop occurs when at least two transport systems repeatedly pass the same message back and forth. Neither system recognizes itself as the final destination, but both know an ostensibly suitable next hop. The loop ends only when a server determines that the permitted number of transport hops has been exceeded and generates an NDR.

In Exchange, two messages are particularly informative:

  • 554 5.4.6 Hop count exceeded - possible mail loop is typically generated by local Exchange.
  • 554 5.4.14 Hop count exceeded - possible mail loop ATTR34 is generated by Exchange Online.

The hop limit is not the cause, but rather the safeguard against endless repetition. Increasing it therefore fixes nothing. The goal is to find the point at which the message is returned to a system it has already passed through, contrary to the target architecture.

Recognizing the Loop Pattern in the Header

The NDR and the complete original message headers should be saved before making any changes. Received lines are read from bottom to top: the bottom line is the earliest documented hop, and the top line is the most recent.

A loop usually appears as a recurring sequence:

Internet
  → Exchange Online Protection
  → Mailgateway
  → Exchange Online Protection
  → Mailgateway
  → Exchange Online Protection
  → ...

Not every Microsoft hostname that appears multiple times is already a loop. Exchange Online processes messages internally through multiple transport roles. What matters is repeated return trips across the same administrative boundaries, for example between Exchange Online and a local gateway. Timestamps, sending IP address, receiving host, and Message-ID help identify the cycle unambiguously.

For the initial analysis, answer these questions:

  1. Which system generated the NDR?
  2. Which two or three hops are repeating?
  3. Which system should have delivered the message finally?
  4. Based on which domain, recipient, connector, or rule decision was it forwarded?
  5. Which change last affected mail flow?

Diagnosis in Exchange Online

Get-MessageTraceV2 can be used to investigate processing over the past 90 days; each query may cover no more than ten days. A narrow time window and the specific recipient address produce the most useful results:

$start = (Get-Date).AddHours(-2)
$end = Get-Date
$recipient = "user01@contoso.com"

$trace = Get-MessageTraceV2 `
    -RecipientAddress $recipient `
    -StartDate $start `
    -EndDate $end `
    -ResultSize 5000

$trace |
    Select-Object Received,SenderAddress,RecipientAddress,Subject,
        Status,FromIP,ToIP,MessageTraceId,MessageId |
    Sort-Object Received
Options explained
OptionEffect
-RecipientAddressFilters the trace for the specified recipient address
-StartDate / -EndDateQuery time window; each query may cover no more than ten days
-ResultSize 5000Maximum number of returned entries
Select-Object …Limits output to the fields relevant to loop analysis
Sort-Object ReceivedSorts results chronologically by acceptance time

The details of a result show individual transport events:

$trace | ForEach-Object {
    Get-MessageTraceDetailV2 `
        -MessageTraceId $_.MessageTraceId `
        -RecipientAddress $_.RecipientAddress
} | Format-Table Date,Event,Action,Detail -AutoSize
Options explained
OptionEffect
-MessageTraceIdUnique trace ID from the result of Get-MessageTraceV2
-RecipientAddressRecipient address of the result; required together with the trace ID for the detail query
Format-Table … -AutoSizeAdjusts column widths to the content so event details remain readable

Then collect the domain, recipient, and connectors together:

Get-AcceptedDomain |
    Format-Table Name,DomainName,DomainType,MatchSubDomains -AutoSize

Get-EXORecipient -Identity $recipient |
    Format-List DisplayName,RecipientTypeDetails,PrimarySmtpAddress,
        ExternalEmailAddress,EmailAddresses

Get-OutboundConnector -IncludeTestModeConnectors |
    Format-List Name,Enabled,ConnectorType,RecipientDomains,SmartHosts,
        UseMXRecord,RouteAllMessagesViaOnPremises,TlsSettings

Get-InboundConnector |
    Format-List Name,Enabled,ConnectorType,SenderDomains,SenderIPAddresses,
        TlsSenderCertificateName,RequireTls,RestrictDomainsToIPAddresses,
        RestrictDomainsToCertificate
Options explained
OptionEffect
-Identity $recipientSelects the recipient object by address, alias, or name
-IncludeTestModeConnectorsAlso includes connectors in test mode in the output
Format-Table … -AutoSizeTable view with content-based column widths
Format-List …List view of the specified properties, suitable for long values such as address lists

What matters is not whether an individual object looks plausible. The domain type, actual recipient type, and applicable connector must all describe the same destination.

Diagnosis in Local Exchange

In a hybrid environment, check the same recipient locally as well. The queries distinguish between a true local mailbox, a RemoteMailbox, and a MailUser:

Get-Recipient -Identity $recipient |
    Format-List DisplayName,RecipientType,RecipientTypeDetails,
        PrimarySmtpAddress,EmailAddresses

Get-Mailbox -Identity $recipient -ErrorAction SilentlyContinue |
    Format-List RecipientTypeDetails,ServerName,Database,PrimarySmtpAddress

Get-RemoteMailbox -Identity $recipient -ErrorAction SilentlyContinue |
    Format-List RecipientTypeDetails,PrimarySmtpAddress,RemoteRoutingAddress

Get-MailUser -Identity $recipient -ErrorAction SilentlyContinue |
    Format-List RecipientTypeDetails,PrimarySmtpAddress,ExternalEmailAddress
Options explained
OptionEffect
-Identity $recipientSelects the object by address, alias, or name
-ErrorAction SilentlyContinueSuppresses the error if the object does not exist in the respective type; the query then simply returns no result

For the transport path, Send and Receive connectors as well as the tracking logs are required:

Get-SendConnector |
    Format-List Name,Enabled,AddressSpaces,DNSRoutingEnabled,SmartHosts,
        SourceTransportServers,CloudServicesMailEnabled,TlsDomain

Get-ReceiveConnector |
    Format-List Identity,Enabled,Bindings,RemoteIPRanges,PermissionGroups

$servers = Get-ExchangeServer |
    Where-Object { $_.IsMailboxServer -or $_.IsHubTransportServer }

$servers |
    Get-MessageTrackingLog `
        -Start $start `
        -End $end `
        -Recipients $recipient `
        -ResultSize Unlimited |
    Select-Object Timestamp,ServerHostname,ClientHostname,Source,EventId,
        ConnectorId,Sender,Recipients,MessageId,NetworkMessageId |
    Sort-Object Timestamp
Options explained
OptionEffect
Where-Object { … }Limits the server list to Mailbox and Hub Transport servers, meaning the roles with tracking logs
-Start / -EndTime window for the log search
-Recipients $recipientFilters for tracking events with this recipient address
-ResultSize UnlimitedRemoves the default limit of 1,000 returned entries
Select-Object …Limits output to the fields relevant to path analysis
Sort-Object TimestampSorts events from all servers chronologically

A SEND to Exchange Online followed by another RECEIVE of the same message from Exchange Online makes the return path visible. MessageId and NetworkMessageId help prevent different test messages from being confused with one another.

The Most Common Causes at a Glance

PatternTypical causeFix
Unknown recipients bounce between two systemsAccepted Domain is set to InternalRelay, but both sides forward unknown recipientsDefine clear responsibility; for complete EXO delivery, use Authoritative, or for a split domain, define a single final hop
EXO sends to local Exchange, which immediately returns it to EXOHybrid connector or Centralized Mail Transport no longer matches the mailbox locationCheck HCW configuration and RouteAllMessagesViaOnPremises; disable obsolete centralized routing or correct local recipient resolution
Message bounces between EXO and a security, signature, or encryption gatewayReturning messages meet the outbound rule againUse the header set by the gateway or its documented loop-prevention mechanism as an exception; clearly authenticate inbound and outbound connectors
Only one recipient is affectedOutdated or incorrect targetAddress, incorrect RemoteMailbox type, or conflicting proxy addressesDetermine the Source of Authority, correct the recipient object there, and synchronize it
Only forwarded messages loopTransport rule, mailbox forwarding, or inbox rule targets the original path againDisable the rule, correct the destination, and define a robust exception
Only one subdomain or application is affectedThe parent domain does not correctly cover the subdomain in the expected connector pathConfigure the subdomain explicitly as an Accepted Domain and in the appropriate Send Connector
All messages loop after a gateway or DNS changeSmart Host or MX points to the sending system’s inbound endpointCorrect the next hop and check DNS, NAT, and load balancer targets separately

Cause 1: Incorrect Accepted Domain Type

An authoritative domain means that all valid recipients for that domain are known in the Exchange organization; unknown recipients are rejected. An Internal Relay domain means that some recipients are located in another system and must be forwarded through a Send or Outbound connector.

The problematic configuration occurs when Exchange Online sends unknown recipients to a local system and that system also does not handle the same domain conclusively, instead returning it to Exchange Online via MX or Smart Host.

Get-AcceptedDomain -Identity contoso.com |
    Format-List DomainName,DomainType,MatchSubDomains
Options explained
OptionEffect
-Identity contoso.comSelects the Accepted Domain to check
Format-List …Displays the domain name, domain type, and subdomain coverage as a list

If all recipients are in Exchange Online after a migration is complete, Authoritative is usually the correct target state:

# Run only after fully checking recipients and routing.
Set-AcceptedDomain -Identity contoso.com -DomainType Authoritative
Options explained
OptionEffect
-Identity contoso.comThe Accepted Domain to change
-DomainType AuthoritativeSets the domain to authoritative: unknown recipients are rejected rather than forwarded

For a genuine split domain, InternalRelay may be correct. However, this requires a clear connector to the system that knows the remaining recipients. That destination must not send unknown addresses back to the starting point.

Cause 2: Overlapping Hybrid Connectors and Centralized Mail Transport

Centralized Mail Transport deliberately routes outgoing Exchange Online messages through local Exchange. This makes sense for specific compliance requirements, but it creates additional transport paths. If the option remains enabled after a migration even though the local system sends messages back to Exchange Online through its own MX, a loop can occur.

Get-OutboundConnector -IncludeTestModeConnectors |
    Format-Table Name,Enabled,ConnectorType,RouteAllMessagesViaOnPremises,
        RecipientDomains,SmartHosts,UseMXRecord -AutoSize
Options explained
OptionEffect
-IncludeTestModeConnectorsAlso includes connectors in test mode in the output
Format-Table … -AutoSizeTable view of routing properties with content-based column widths

Multiple connectors with overlapping scope should also be checked. Microsoft recommends a dedicated on-premises connector for hybrid mail flow; repairing it with the Hybrid Configuration Wizard is often safer than isolated individual changes.

If Centralized Mail Transport is demonstrably no longer needed, the setting can be disabled specifically:

# Only after checking compliance and gateway requirements.
Set-OutboundConnector `
    -Identity "Outbound to On-Premises" `
    -RouteAllMessagesViaOnPremises:$false
Options explained
OptionEffect
-Identity "Outbound to On-Premises"The Outbound Connector to change
-RouteAllMessagesViaOnPremises:$falseDisables Centralized Mail Transport: outgoing Exchange Online messages no longer pass through local Exchange

Cause 3: A Gateway Processes Its Return Messages Again

In an in-and-out scenario, Exchange Online sends a message to an additional service for signing, encryption, or archiving. The service then returns it to Exchange Online. The outbound rule must recognize the returning message; otherwise, it is sent to the service again.

Start by checking all rules that select connectors, redirect recipients, or evaluate headers:

Get-TransportRule |
    Sort-Object Priority |
    Format-List Name,State,Mode,Priority,FromScope,SentToScope,
        RedirectMessageTo,RouteMessageOutboundConnector,
        SetHeaderName,SetHeaderValue,ExceptIfHeaderContainsMessageHeader,
        ExceptIfHeaderContainsWords
Options explained
OptionEffect
Sort-Object PrioritySorts rules in their evaluation order
Format-List …Displays properties that select connectors, redirect recipients, or set headers or evaluate them as exceptions

The specific exception must follow the gateway vendor’s documentation. A header set by the service that cannot be spoofed trustworthily from the Internet is common. In addition, inbound connectors should identify the service by certificate or fixed sender IP address. A blanket exception for all messages that appear “internal” is too broad.

Cause 4: The Recipient Object and Actual Mailbox Are Not in the Same Location

An object can appear in Exchange Online as a MailUser even though the active mailbox is located locally. In a synchronized hybrid environment, this is not automatically a duplicate. Nor does an ExternalEmailAddress matching the primary SMTP address alone prove a misconfiguration.

The combination of all queries is decisive:

  • Local Get-Mailbox returns a result: The active mailbox is local.
  • Local Get-RemoteMailbox returns a result: The managed destination is in Exchange Online.
  • Get-EXOMailbox returns a result: A true mailbox exists in the cloud.
  • Get-EXORecipient returns only a MailUser: The object is a routing destination, not a cloud mailbox.

Outdated objects after a migration, incorrect remote routing domains, or manually set targetAddress values whose domain routes back through the same transport path are problematic. Changes must be made at the Source of Authority: in synchronized environments, use Exchange management tools locally rather than directly editing individual attributes in Exchange Online.

Cause 5: Forwarding and Transport Rules Form a Loop

A rule can redirect from address A to B, while B sends back to A through a second rule, mailbox forwarding, or an external system. Such loops often affect only individual recipients or message types.

Get-TransportRule |
    Sort-Object Priority |
    Select-Object Name,State,Mode,Priority,RedirectMessageTo,
        BlindCopyTo,AddToRecipients,RouteMessageOutboundConnector

Get-Mailbox -ResultSize Unlimited |
    Select-Object DisplayName,PrimarySmtpAddress,
        ForwardingAddress,ForwardingSmtpAddress,DeliverToMailboxAndForward

Get-InboxRule -Mailbox user01@contoso.com |
    Select-Object Name,Enabled,Priority,ForwardTo,RedirectTo,ForwardAsAttachmentTo
Options explained
OptionEffect
Sort-Object PrioritySorts transport rules in their evaluation order
-ResultSize UnlimitedRemoves the default limit of 1,000 returned mailboxes
-Mailbox user01@contoso.comMailbox whose inbox rules are queried
Select-Object …Limits output to forwarding and redirection destinations

The fix is not merely to disable a rule temporarily. The entire chain must be resolved, and rules for external services require an exception that reliably recognizes messages already processed.

Cause 6: MX, Smart Host, or Subdomain Points Back

A gateway may require a different next hop internally than external senders do. If it simply uses the public MX for forwarding, that MX may point back to the gateway itself. The same problem arises if a Smart Host routes back to its own listener through NAT or load balancing.

Resolve-DnsName -Type MX contoso.com
Resolve-DnsName -Type MX app.contoso.com

Get-SendConnector |
    Format-List Name,AddressSpaces,DNSRoutingEnabled,SmartHosts
Options explained
OptionEffect
-Type MXQueries MX records instead of the default A records
contoso.com / app.contoso.comDomain to query as a positional argument (parameter -Name)
Format-List …Displays address spaces, routing mode, and Smart Hosts for each Send Connector

Subdomains deserve separate review. In a support article that has since been withdrawn, Microsoft documented cases in which an application subdomain must be explicitly created as an Internal Relay domain and synchronized to the Edge systems:

New-AcceptedDomain `
    -Name "app.contoso.com" `
    -DomainName app.contoso.com `
    -DomainType InternalRelay

Start-EdgeSynchronization
Options explained
OptionEffect
-Name "app.contoso.com"Display name of the new Accepted Domain object
-DomainName app.contoso.comThe SMTP domain for which Exchange accepts messages
-DomainType InternalRelaySome recipients are outside the organization; unknown recipients are forwarded through a Send Connector rather than rejected

These commands are not a universal fix. They apply only if app.contoso.com is actually delivered outside the Exchange organization and the Send Connector has an unambiguous next hop.

Safe Procedure for an Active Loop

During the disruption, first stop the multiplication. Depending on the architecture, the triggering transport rule or specific connector is disabled in a controlled manner, or the gateway holds back the affected queue. Export the configuration and message samples beforehand.

Then test with exactly one sender, one recipient, and a clearly identifiable subject line. Trace the message end to end through headers, Message Trace, and local tracking logs. Only once it ends at the intended destination should mail flow be gradually reopened.

Not recommended:

  • Increasing hop limits
  • Changing multiple connectors at the same time
  • Switching Accepted Domains back and forth between Authoritative and InternalRelay on suspicion
  • Repeatedly resubmitting a problematic queue without verification
  • Correcting synchronized Exchange attributes directly in AD or Exchange Online
  • Disabling TLS, IP, or certificate checks as an alleged quick fix

Final Verification

After the correction, the documentation should contain exactly one statement for each relevant domain: Which system knows the recipient, which connector applies, and which host is the final next hop?

Technical acceptance includes at least:

  • External and internal test messages
  • Unknown recipient in the same domain
  • Recipient on each side of a genuine split domain
  • Outgoing message with a gateway or Centralized Mail Transport enabled
  • Headers without a recurring hop sequence
  • Message Trace with Delivered or the expected handoff
  • Local tracking without another RECEIVE after a SEND to the same destination
  • Connector validation for all connectors still required

A fixed mail loop is complete only when not just the test message arrives, but unknown recipients and alternative mail flow paths also end in defined ways. That is where most recurrences occur.

Change History

  • October 25, 2026: Microsoft withdrew the support article about the subdomain and EdgeSync scenario; the source now refers to the archived version from April 19, 2026.

Sources

  1. Microsoft Learn – Fix NDR error 5.4.6 or 5.4.14 in Exchange Online
  2. Microsoft Learn – Manage accepted domains in Exchange Online
  3. Microsoft Learn – Accepted domains in Exchange Server

    Responsibilities, relay domains, and recipient lookup in local Exchange.

    https://learn.microsoft.com/en-us/exchange/mail-flow/accepted-domains/accepted-domains
  4. Microsoft Learn – Transport routing in Exchange hybrid deployments

    Expected transport paths with and without Centralized Mail Transport.

    https://learn.microsoft.com/en-us/exchange/transport-routing
  5. Microsoft Learn – Validate connectors in Exchange Online
  6. Microsoft Learn – Manage mail flow using a third-party cloud service
  7. Microsoft Learn – Mail flow rules in Exchange Online
  8. Microsoft Learn – Get-MessageTraceV2
  9. Microsoft Learn – Search message tracking logs
  10. Microsoft Learn – Hop count exceeded for an on-premises application subdomain (archived version from April 19, 2026)

    Documented subdomain/EdgeSync scenario with an explicit Internal Relay domain; Microsoft has since withdrawn the article.

    https://web.archive.org/web/20260419203247/https://learn.microsoft.com/en-us/troubleshoot/exchange/mailflow/hop-count-exceeded-possible-mail-loop

Comments

Comments are loaded from GitHub / Giscus.