Loop Prevention in Exchange Online Demystified

Published May 03 2021 06:45 AM 14.4K Views

We often get questions regarding mail forwarding in Exchange Online. As you already know, Exchange Online is a shared service. We must take care that users cannot take the service down by creating mail loops. It is sometimes a little confusing for our customers that we handle this somewhat differently than in Exchange on-premises organizations. With this blog post we will give you an overview of how we handle possible mail loop scenarios and how this affects your mail flow. If you are the kind of a person that loves digging into the details, this post is for you!

Mail loop insight in the Security & Compliance Center

You may have ended up here because you ran into a possible mail loop scenario. This blog post should help you to get a better understanding about how we handle possible mail loop scenarios, how they can occur and what to do to prevent them. I recommend checking the Fix possible mail loop insight in the Recommended for you area of the Mail flow dashboard in the Security & Compliance Center (protection.office.com) or the converged security portal (security.microsoft.com). It notifies you when a mail loop is detected in your organization.

Read on now if you want to get deeper insights about our loop prevention mechanisms.

Currently stamped and preserved X-headers

It’s important to know that there are some headers which get preserved across Exchange organizational boundaries and most of them will not be removed during transport (neither by Exchange Header Firewall nor using transport rules). These headers are:

  • X-MS-Exchange-Inbox-Rules-Loop
  • X-MS-Exchange-Transport-Rules-Loop
  • X-MS-Gcc-Journal-Report
  • X-MS-Exchange-Moderation-Loop
  • X-MS-Exchange-Generated-Message-Source
  • X-LD-Processed
  • X-MS-Exchange-ForwardingLoop
  • X-EOPAttributedMessage
  • X-EOPTenantAttributedMessage

Please keep in mind that we might change these headers without notice. The purpose of this list is only to provide an overview of different headers we use to prevent loops in the service. Please do not rely on them if you construct business-critical workflows.

To get a better understanding of how loop prevention in Exchange Online works, we will have a look at most of these headers.

X-MS-Exchange-Inbox-Rules-Loop header

First things first: in the cloud, the number of times a message can be redirected, forwarded, or replied to automatically is limited to 1. On-premises Exchange servers are limited to 3 (as documented here).

We set this header for example in the following scenarios:

  • User created an inbox rule which forwards the message to another recipient
  • User created an inbox rule which redirects the message to another recipient

The value of this header denotes the original recipient of the mail (one which has a mailbox rule to forward to the new recipient in To: header). It looks like this:

X-MS-Exchange-Inbox-Rules-Loop: john.doe@contoso.com

If you run an extended message trace:

Start-HistoricalSearch -ReportType MessageTraceDetail -ReportTitle Inbox-Rules-Loop -MessageID “<1234567890123456789012345678901@AM0PR04MB6531.eurprd04.prod.outlook.com>” -NotifyAddress john.doe@contoso.com -StartDate 05/09/2020 -EndDate 05/10/2020

And you find something like this:

Source: MAILBOXRULE
event_id: THROTTLE
reference: XLoopHeaderCount:1/1

It means that the message got silently dropped because it has reached datacenters X-MS-Exchange-Inbox-Rules-Loop limit which is (as described above) 1.

Mostly important for Exchange Online customers who run an on-premises Exchange organization in a Hybrid configuration: we also check if current recipient mail address is already present within an X-MS-Exchange-Inbox-Rules-Loop header for incoming messages. If that is the case, then we silently drop the message as well (not yet relevant in Exchange Online because the X-MS-Exchange-Inbox-Rules-Loop limit is currently 1 which means we drop the message if any X-MS-Exchange-Inbox-Rules-Loop header exists when the message arrives, regardless of which address the header contains).

X-MS-Exchange-Transport-Rules-Loop header

We set this header in the following scenario:

Mail gets redirected or recipients are added (To, Cc, Bcc) by an Exchange transport rule (ETR)

If the value of this header exceeds its thresholds (in the cloud, the number of times a message can be redirected or forwarded automatically by using a transport rule is limited to 1 - please have a look at Scenario 2 in the Real-life examples – what is the impact on email? how this can happen), we then stop processing, drop the message, log the event, and finally send out an NDR to the original sender like this:

550 5.7.128 TRANSPORT.RULES.RejectMessage; Transport rules loop count exceeded and message rejected

Note: We do not send an NDR to the original sender for any recipient added to Bcc by an Exchange transport rule during the mail flow (we only NDR for To and Cc type recipients).

X-MS-Exchange-Moderation-Loop header

Example scenario when we set this header:

  • When a message is forwarded for approval, we stamp this header into the approval message followed by arbitration mailbox SMTP address:

X-MS-Exchange-Moderation-Loop: SPO_Arbitration_fa627f00-12d2-4d68-bd5d-75cd62ead0ee@M365x777241.onmicrosoft.com

  • We allow at maximum 1 header. If there are more headers in place, we are going to silently drop the approval message.

You will find the following smtp status logged when running a message trace:

550 5.2.0 Resolver.MT.ModerationLoop; Loop in approval process

X-LD-Processed header

We use this header to track transport processing on a per tenant basis:

  • To track potential loops due to mail contact ExternalEmailAddress (TargetAddress) redirection
  • If forwarding is configured using the Set-Mailbox -ForwardingSMTPAddress or -ForwardingAddress parameter

If an action like this was detected from our service, we stamp the header followed by the ID of the tenant and a list of strings indicating the list of work that is being tracked.

This may be:

  • ExtAddr if we are doing an external redirection by using ExternalEmailAddress
  • ExtFwd if we are doing external forwarding by using ForwardingSMTPAddress or ForwardingAddress

If the message is redirected or forwarded to another tenant, we add another X-LD-Processed header containing the tenants ID (we do not replace any existing X-LD-Processed header). If the message comes from an external address and is redirected to another external address, we also stamp the Resent-From header to indicate that Exchange has touched it.

We allow a maximum of 3 loops per tenant for ExternalEmailAddress (TargetAddress) or ForwardingAddress/ForwardingSmtpAddress.

If we exceed the number of forwards, we track the following smtp event (you can find the event by running a message trace). We do not send out an NDR to prevent further loops:

550 5.4.142 RESOLVER.FWD.LoopingTarget; forwarding to a looping external address

We also detect if there is a loop within the directory. You normally should not run into this kind of loop. It can occur, for example, when a mailbox has forwarding configured and ForwardingAddress refers to itself. This job is done while the message is processed. If we detect a loop here, the message will be dropped and we NDR the sender with:

550 5.4.6 RESOLVER.FWD.Loop; there is a forwarding loop configured in the directory

X-MS-Exchange-ForwardingLoop header

This header is added when forwarding happens due to ForwardingSmtpAddress or ForwardingAddress properties set on a mailbox. In the case where the mailbox also has DeliverToMailboxAndForward:$true, when recipient A forwards a message to recipient B, there will be two copies of the message. One to the original recipient A and the other to the forwarded recipient B. The value of the header in the message to the forwarded recipient B will contain <SmtpAddressOfOriginalRecipient>;<TenantGuidOfOriginalRecipient>. The header looks like this:

X-MS-Exchange-ForwardingLoop: JDoe@contoso.com;53bb1ab7-edea-4e35-8c3f-e395807764bf

The purpose of this header is to detect forwarding loops like A forwards to B and B forwards to A.  If B attempts to forward to A, the message will be dropped with the smtp response:

550 5.4.142 RESOLVER.FWD.LoopingTarget; forwarding to a looping external address

The message copy to the original recipient A will also have this header added with the value ForwardingHandled;< TenantGuidOfOriginalRecipient>. It looks like this one:

X-MS-Exchange-ForwardingLoop: ForwardingHandled;53bb1ab7-edea-4e35-8c3f-e395807764bf

The purpose of this header with ForwardingHandled value is to prevent forwarding message multiple times in scenarios like Centralized Mail Transport (aka CMT or CMC), where the message to the original recipient is routed out of the service and then back to the service. In a CMC scenario the message will be forwarded first when the message enters the service. When the message gets routed out and sent back to the service, duplicate forwarding will be prevented by looking at this header in the message. Please have a look at Scenario 5 at the end of this post to get a better understanding of the workflow in CMC scenario.

Note: Customers sometimes make use of the X-MS-Exchange-Inbox-Rules-Loop header to check if a message was forwarded to forwarding address or forwarding SMTP address of the mailbox. If you are doing so, you should now use the new X-MS-Exchange-ForwardingLoop header instead.

X-MS-Exchange-Generated-Message-Source header

This header is used to check for loops in Exchange agent-generated messages. In Exchange Online, we do this while they are in submission and smtp process. We make use of this header for example if an automatic reply via inbox rule is in place. We then stamp the following headers:

X-Auto-Response-Suppress: All
X-MS-Exchange-Inbox-Rules-Loop: john.doe@contoso.com
auto-submitted: auto-generated
X-MS-Exchange-Generated-Message-Source: Mailbox Rules Agent

Let us have a closer look at these X-headers:

  • X-Auto-Response-Suppress
    • Specifies whether a client or server application will forego sending automated replies in response to this message. There are different values available. In case of an automatic reply, Exchange sets the value to All.
  • X-MS-Exchange-Inbox-Rules-Loop
    • Please have a look at 1) X-MS-Exchange-Inbox-Rules-Loop
  • auto-submitted
    • Defined in RFC 3834. Let me quote from there:

“The purpose of the Auto-Submitted header field is to indicate that the message was originated by an automatic process, or an automatic responder, rather than by a human; and to facilitate automatic filtering of messages from signal paths for which automatically generated messages and automatic responses are not desirable.”

  • X-MS-Exchange-Generated-Message-Source
    • Short: This X-header is used to prevent mail loops caused by agent-generated messages.
    • Long: If this header is present, it means that the mail you see is an agent-generated message. We check if it does not exceed our limits. We do these checks while the message is processed in submission and smtp. There are different limits in place. If the message is an inter-tenant one (means no intra-tenant organization header exists), we limit this to 3 agents, and they may be the same (for example three times DLP Policy Agent).

You will see multiple agents for example if you have DLP in place and an inbox rule which redirects every message to another mailbox. If your DLP policy matches and you receive a mail notification that gets redirected to another mailbox, you will see something like this:

X-MS-Exchange-Generated-Message-Source: DLP Policy Agent,Mailbox Rules Agent.

If the message is an intra-tenant one, we limit this to a maximum of 2 Exchange agents. Side effect messages are, for example, intra-tenant messages. This kind of messages are generated after a message has been delivered to the mailbox. For example, a message delivered to a mailbox triggers an auto reply or inbox rule that redirects the message to another recipient. In this case, a side effect message is generated. We drop the message if the Exchange agent is the same (for example two times DLP Policy Agent). While in progress, side effect messages are stamped with the following header which is replaced after the message has been delivered.

X-MS-Exchange-Organization-Generated-Message-Source: Mailbox Rules Agent

Some more loop protection insights

We also detect incoming messages that are looping when they pass Exchange Online Protection (EOP). We count every time a message passes through EOP frontdoor and we reject every message that reaches our thresholds. Let me explain this in a little more detail.

To do this, we need some more headers. As this is EOP related work, the headers are named like this:

  • X-EOPAttributedMessage
  • X-EOPTenantAttributedMessage
  • Some more internal loop prevention headers for routing to quarantine and ATP

We increase the X-EOPAttributedMessage header every time the message is processed by EOP frontdoor. It looks like this:

X-EOPAttributedMessage: 1

We also stamp the X-EOPTenantAttributedMessage header with tenant guid and a number which shows how often the message was processed through this tenants EOP. A valid header of a messages that passes EOP for the first time looks like this:

X-EOPTenantAttributedMessage: 543b1ab7-eeea-4a35-8c3f-e396007764bf:0

If the message is re-routed through another tenant (for example, an ETR in Tenant A automatically forwards the message to Tenant B), the X-EOPTenantAttributedMessage header is reset. Anyway, the X-EOPAttributedMessage count is kept and increased. We drop the message if it goes several times through the same tenant (X-EOPTenantAttributedMessage) or when it exceeds a threshold of several more message being routed between different tenants).

If we exceed the number of total hops (which is currently 7 but it but can be changed in the future without being separate announced), you can find the following smtp response logged:

554 5.4.14 Hop count exceeded - possible mail loop ATTR1

If we exceed the hop count within the same tenant (which is currently 3 but can be changed in the future without separate announcement), we then NDR this one out:

554 5.4.14 Hop count exceeded - possible mail loop ATTR34

If you see any of the following smtp responses logged, you then should be open a support case for further investigation. We protocol these if a threshold associated with quarantine or ATP has been reached and a message has been dropped by the service:

454 4.4.15 Hop count exceeded - possible mail loop ATTR39

454 4.4.15 Hop count exceeded - possible mail loop ATTR40

Real-life examples – what is the impact on email?

Here are some examples of how all of this may affect your mail flow:

MailLoop01.jpg

Scenario 1:

John Doe (Contoso Ltd.) creates an inbox rule to redirect every message to Mike Meyer (TailSpin Toys). Mike in turn has another inbox rule in place to redirect every incoming message to Anna Smith (Fabrikam, Inc.).

Result:

In this case, Exchange stamps the X-MS-Exchange-Inbox-Rules-Loop: John.Doe@contoso.com header after the first redirect is processed. Exchange at TailSpin Toys detects that header (message tracking reference will log XLoopHeaderCount:1/1) and does not redirect the message again. In this case Mike Meyer will not get an NDR. As an administrator you will find this event by running a message trace.

This scenario is one of the most seen and we must be very restrictive because customers can easily build a loop here. Therefore, we restrict this to only 1 redirect/forward by using inbox rules. This limit is hardcoded and cannot be changed. If you make use of Exchange on-premises, it is possible to have up to 3 redirects by inbox rules in place. As an administrator it is your task to protect your users from building loops. 

MailLoop02.jpg

Scenario 2:

In this scenario we make use of two transport rules. The first one, located at Contoso’s Exchange organization, redirects every message addressed to John.Doe@contoso.com and coming from outside the organization, to Mike Meyer at TailSpin Toys company:

MailLoop03.jpg

At TailSpin Toys there is also a transport rule in place, to Bcc incoming messages to Anna Smith at Fabrikam:

MailLoop04.jpg

Result:

In this case the message is stamped at transport within Contoso organization. We see the X-MS-Exchange-Transport-Rules-Loop: 1 header. At TailSpin Toys the message is dropped due to X-MS-Exchange-Transport-Rules-Loop: 1 header. If you run a message trace, you will find the following event logged:

550 5.7.128 TRANSPORT.RULES.RejectMessage; Transport rules loop count exceeded and message rejected

Remember: We do not send out an NDR to the original sender. This is because of the second transport rule which is configured to add an additional recipient as BCC into the message. If the second transport rule is configured to add an CC-Recipient or simply redirects the message instead of an additional recipient as BCC, an NDR will be send out to the original sender.

MailLoop05.jpg

Scenario 3:

In this scenario we are going to have a look at the moderation loop protection. We have a transport rule (2) that forwards every message, send from outside the organization to shared@fabrikam.com, to Anna Smith for approval (3). Anna is going to holiday and so she has created an inbox rule to redirect every message to the marketing team (4). Unfortunately, the marketing distribution list is also moderated.

Result:

In this case, the moderation message is stamped with the X-MS-Exchange-Moderation-Loop header, followed by the smtp address of the arbitration mailbox:

X-MS-Exchange-Moderation-Loop: SPO_Arbitration_fa627f00-12d2-4d68-bd5d-75cd62ead0ee@M365x777241.onmicrosoft.com

The approval request which is forwarded via inbox rule from Anna’s mailbox to the marketing distribution list is dropped and no NDR is send out to the original sender. If you run a message trace, you will find the following smtp response stamped:

550 5.2.0 Resolver.MT.ModerationLoop; Loop in approval process

MailLoop06.jpg

Scenario 4:

In this scenario we are going to have a look at the X-LD-Processed header and how it works. Assumed we have the following setup: We have two companies – TailSpin Toys and Fabrikam. Both have marketing departments working together. To make this workflow easier, they decide to create mail users for each other company department (Marketing-Fabrikam and Marketing-TailSpin). Unfortunately, someone added the mail users to the local marketing distribution list – and the loop begins.

Result:

What happens here? Someone sends a mail to one of the distribution lists. Exchange expands the list and starts processing the item. For the first time the mail gets processed, we check on transport if any X-LD-Processed header followed by tenants guid is present. If this is not the case, we stamp a header like this:

X-LD-Processed: 6249f43a-676b-4124-a13a-50205140b751,ExtAddr

We do this also for the other tenant. So one more X-LD-Processed header is added:

X-LD-Processed: 53bb1ab7-edea-4e35-8c3f-e395807764bf,ExtAddr

We keep doing this every time the message is processed and at the end (after the message was processed for the 3rd time), the header looks like this:

X-LD-Processed: 6249f43a-676b-4124-a13a-50205140b751,ExtAddr,ExtAddr,ExtAddr

X-LD-Processed: 53bb1ab7-edea-4e35-8c3f-e395807764bf,ExtAddr,ExtAddr,ExtAddr

If the message enters transport again, it will be dropped and NDR is send out to the original sender:

554 5.4.14 Hop count exceeded - possible mail loop ATTR1 [HE1EUR04FT048.eop-eur04.prod.protection.outlook.com]

And so, the loop ends.

MailLoop07.jpg

Scenario 5:

In this scenario we are going to have a look at the X-MS-Exchange-ForwardingLoop header and how it works. Assumed we have the following setup: Fabrikam has a Hybrid configuration and have also enabled Centralized Mail Transport (CMT; also known as CMC, RouteAllMessagesViaOnPremises enabled on the outbound connector). MX points to the Exchange Online service to make use of our malware and spam protection features. They need to route all outgoing messages through Exchange on-premises because of their mail signature and DLP solution which has not been migrated to cloud yet. Anna Smith of Fabrikam has set ForwardingSmtpAddress to John.Doe@contoso.com as well as DeliverToMailboxAndForward set to $true.

Result:

A message addressed to Anna.Smith@fabrikam.com enters the service (1). We notice that ForwardingSmtpAddress is set to John.Doe@contoso.com as well as DeliverToMailboxAndForward is set to $true. Now message bifurcation kicks in and creates another copy of the message. The message which goes to John.Doe@contoso.com gets stamped (2a) with following header:

X-MS-Exchange-ForwardingLoop: Anna.Smith@fabrikam.com;53bb1ab7-edea-4e35-8c3f-e395807764bf

And is routed through Exchange on-premises to John.Doe@contoso.com. Unfortunately, there is also ForwardingSmtpAddress set on John Doe’s mailbox which points to Anna.Smith@fabrikam.com. The message is now routed to the Exchange Online service again (3a). Here we detect that X-MS-Exchange-ForwardingLoop has already been set with that recipient and tenant guid. Result of this is that we drop the message with smtp response:

550 5.4.142 RESOLVER.FWD.LoopingTarget; forwarding to a looping external address

The original message copy to Anna Smith’s mailbox is also on its way. This message also makes an extra round through Exchange on-premises due to requirement imposed by having CMC enabled and it’s coming from Internet (i.e. not having passed through on-premises yet). Before being sent to on-premises, however, this copy was stamped with a header (2b). It looks a little different to the header mentioned before:

X-MS-Exchange-ForwardingLoop: ForwardingHandled;53bb1ab7-edea-4e35-8c3f-e395807764bf

As you can see, it contains ForwardingHandled instead of the recipient’s e-mail address. We need to do this in order to remember that Forwarding was already applied in cases when the message then has a routing requirement out of the EXO service such as Centralized Mail Transport. When on-premises sends it back to Exchange Online (3b), we now figure out that the X-MS-Exchange-ForwardingLoop header has already been stamped with ForwardingHandled flag. Result of this is that we don’t forward the message again (no RESOLVER REDIRECT event in Message Tracking Log/Message Trace Details Report). The message is finally delivered to Anna Smith’s mailbox (4b).

What if I need to do multiple forwards or redirects for handling business processes?

Glad you asked! Basically, there are 3 ways to go:

  • Keep these mailboxes on-premises (which is not a real option if you want to use the awesome features available in Exchange Online). Remember: Some limits are different when using Exchange on-premises.
  • Configure redirect via Set-Mailbox -ForwardingSMTPAddress or -ForwardingAddress parameter. As described above, we make use of the X-LD-Processed header in this scenario which allows up to 3 redirects per tenant.
  • Make use of Microsoft Power Automate. With Power Automate you can create automated workflows between your favorite apps and services in a centralized way. This includes many email actions when using the Microsoft 365 Outlook Connector. I encourage you to check out the documentation, give it a try and see the power of this Microsoft Power Platform application.

MailLoop08.jpg

I hope all these insights help you to get a better overview and understanding of how we handle possible loop situations in Exchange Online. It is sometimes a little confusing and may look complicated, but keeping the service running for our customers is a must.

Special thanks to all contributors: Especially to Stan Aleksiev for taking care of the technical review, Arindam Thokder, Dan Li, Guru Prasad, Arnold Kermer and Dmitry Starostin!

Lukas Sassl

3 Comments
Contributor

I ran into a situation where we had a Shared Mailbox that replied to an email address that it had received the email but the ReplyTo address responded that it was an unmanaged mailbox and that emails would be ignored. This went on until our Shared Mailbox hit the hourly External Send Email limit and was shut down for the remainder of the day.

How could we have stopped that loop from happening?

 

Thank you,

Shaun

Microsoft

@Shaun Jennings I’ve dropped you a PM. Need some more information (headers etc.) to get a better understanding  of your scenario.

Contributor

@Lukas Sassl  I will see if those tracking logs are still in place and I can find the headers for you. It was an interesting loop.

%3CLINGO-SUB%20id%3D%22lingo-sub-2317969%22%20slang%3D%22en-US%22%3ERe%3A%20Loop%20Prevention%20in%20Exchange%20Online%20Demystified%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2317969%22%20slang%3D%22en-US%22%3E%3CP%3EI%20ran%20into%20a%20situation%20where%20we%20had%20a%20Shared%20Mailbox%20that%20replied%20to%20an%20email%20address%20that%20it%20had%20received%20the%20email%20but%20the%20ReplyTo%20address%20responded%20that%20it%20was%20an%20unmanaged%20mailbox%20and%20that%20emails%20would%20be%20ignored.%20This%20went%20on%20until%20our%20Shared%20Mailbox%20hit%20the%20hourly%20External%20Send%20Email%20limit%20and%20was%20shut%20down%20for%20the%20remainder%20of%20the%20day.%3CBR%20%2F%3E%3CBR%20%2F%3EHow%20could%20we%20have%20stopped%20that%20loop%20from%20happening%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThank%20you%2C%3C%2FP%3E%3CP%3EShaun%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2318264%22%20slang%3D%22en-US%22%3ERe%3A%20Loop%20Prevention%20in%20Exchange%20Online%20Demystified%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2318264%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F221635%22%20target%3D%22_blank%22%3E%40Shaun%20Jennings%3C%2FA%3E%26nbsp%3BI%E2%80%99ve%20dropped%20you%20a%20PM.%20Need%20some%20more%20information%20(headers%20etc.%20to%20better%20understand%20your%20scenario).%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2318563%22%20slang%3D%22en-US%22%3ERe%3A%20Loop%20Prevention%20in%20Exchange%20Online%20Demystified%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2318563%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F164282%22%20target%3D%22_blank%22%3E%40Lukas%20Sassl%3C%2FA%3E%26nbsp%3B%20I%20will%20see%20if%20those%20tracking%20logs%20are%20still%20in%20place%20and%20I%20can%20find%20the%20headers%20for%20you.%20It%20was%20an%20interesting%20loop.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2312258%22%20slang%3D%22en-US%22%3ELoop%20Prevention%20in%20Exchange%20Online%20Demystified%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2312258%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20often%20get%20questions%20regarding%20mail%20forwarding%20in%20Exchange%20Online.%20As%20you%20already%20know%2C%20Exchange%20Online%20is%20a%20shared%20service.%20We%20must%20take%20care%20that%20users%20cannot%20take%20the%20service%20down%20by%20creating%20mail%20loops.%20It%20is%20sometimes%20a%20little%20confusing%20for%20our%20customers%20that%20we%20handle%20this%20somewhat%20differently%20than%20in%20Exchange%20on-premises%20organizations.%20With%20this%20blog%20post%20we%20will%20give%20you%20an%20overview%20of%20how%20we%20handle%20possible%20mail%20loop%20scenarios%20and%20how%20this%20affects%20your%20mail%20flow.%20If%20you%20are%20the%20kind%20of%20a%20person%20that%20loves%20digging%20into%20the%20details%2C%20this%20post%20is%20for%20you!%3C%2FP%3EMail%20loop%20insight%20in%20the%20Security%20%26amp%3B%20Compliance%20Center%3CP%3EYou%20may%20have%20ended%20up%20here%20because%20you%20ran%20into%20a%20possible%20mail%20loop%20scenario.%20This%20blog%20post%20should%20help%20you%20to%20get%20a%20better%20understanding%20about%20how%20we%20handle%20possible%20mail%20loop%20scenarios%2C%20how%20they%20can%20occur%20and%20what%20to%20do%20to%20prevent%20them.%20I%20recommend%20checking%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fmicrosoft-365%2Fsecurity%2Foffice-365-security%2Fmfi-mail-loop-insight%3Fview%3Do365-worldwide%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3EFix%20possible%20mail%20loop%20insight%3C%2FA%3E%20in%20the%20Recommended%20for%20you%20area%20of%20the%20Mail%20flow%20dashboard%20in%20the%20Security%20%26amp%3B%20Compliance%20Center%20(protection.office.com)%20or%20the%20converged%20security%20portal%20(security.microsoft.com).%20It%20notifies%20you%20when%20a%20mail%20loop%20is%20detected%20in%20your%20organization.%3C%2FP%3E%3CP%3ERead%20on%20now%20if%20you%20want%20to%20get%20deeper%20insights%20about%20our%20loop%20prevention%20mechanisms.%3C%2FP%3ECurrently%20stamped%20and%20preserved%20X-headers%3CP%3EIt%E2%80%99s%20important%20to%20know%20that%20there%20are%20some%20headers%20which%20get%20preserved%20across%20Exchange%20organizational%20boundaries%20and%20most%20of%20them%20will%20not%20be%20removed%20during%20transport%20(neither%20by%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fexchange%2Fheader-firewall-exchange-2013-help%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3EExchange%20Header%20Firewall%3C%2FA%3E%20nor%20using%20transport%20rules).%20These%20headers%20are%3A%3C%2FP%3EX-MS-Exchange-Inbox-Rules-Loop%20X-MS-Exchange-Transport-Rules-Loop%20X-MS-Gcc-Journal-Report%20X-MS-Exchange-Moderation-Loop%20X-MS-Exchange-Generated-Message-Source%20X-LD-Processed%20X-MS-Exchange-ForwardingLoop%20X-EOPAttributedMessage%20X-EOPTenantAttributedMessage%3CP%3EPlease%20keep%20in%20mind%20that%20we%20might%20change%20these%20headers%20without%20notice.%20The%20purpose%20of%20this%20list%20is%20only%20to%20provide%20an%20overview%20of%20different%20headers%20we%20use%20to%20prevent%20loops%20in%20the%20service.%20Please%20do%20not%20rely%20on%20them%20if%20you%20construct%20business-critical%20workflows.%3C%2FP%3E%3CP%3ETo%20get%20a%20better%20understanding%20of%20how%20loop%20prevention%20in%20Exchange%20Online%20works%2C%20we%20will%20have%20a%20look%20at%20most%20of%20these%20headers.%3C%2FP%3EX-MS-Exchange-Inbox-Rules-Loop%20header%3CP%3EFirst%20things%20first%3A%20in%20the%20cloud%2C%20the%20number%20of%20times%20a%20message%20can%20be%20redirected%2C%20forwarded%2C%20or%20replied%20to%20automatically%20is%20limited%20to%201.%20On-premises%20Exchange%20servers%20are%20limited%20to%203%20(as%20documented%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice365%2Fservicedescriptions%2Fexchange-online-service-description%2Fexchange-online-limits%23journal-transport-and-inbox-rule-limits%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3Ehere%3C%2FA%3E).%3C%2FP%3E%3CP%3EWe%20set%20this%20header%20for%20example%20in%20the%20following%20scenarios%3A%3C%2FP%3EUser%20created%20an%20inbox%20rule%20which%20forwards%20the%20message%20to%20another%20recipient%20User%20created%20an%20inbox%20rule%20which%20redirects%20the%20message%20to%20another%20recipient%3CP%3EThe%20value%20of%20this%20header%20denotes%20the%20original%20recipient%20of%20the%20mail%20(one%20which%20has%20a%20mailbox%20rule%20to%20forward%20to%20the%20new%20recipient%20in%20To%3A%20header).%20It%20looks%20like%20this%3A%3C%2FP%3E%3CP%3EX-MS-Exchange-Inbox-Rules-Loop%3A%20john.doe%40contoso.com%3C%2FP%3E%3CP%3EIf%20you%20run%20an%20extended%20message%20trace%3A%3C%2FP%3E%3CP%3EStart-HistoricalSearch%20-ReportType%20MessageTraceDetail%20-ReportTitle%20Inbox-Rules-Loop%20-MessageID%20%E2%80%9C%26lt%3B1234567890123456789012345678901%40AM0PR04MB6531.eurprd04.prod.outlook.com%26gt%3B%E2%80%9D%20-NotifyAddress%20john.doe%40contoso.com%20-StartDate%2005%2F09%2F2020%20-EndDate%2005%2F10%2F2020%3C%2FP%3E%3CP%3EAnd%20you%20find%20something%20like%20this%3A%3C%2FP%3E%3CP%3ESource%3A%20MAILBOXRULE%3CBR%20%2F%3Eevent_id%3A%20THROTTLE%3CBR%20%2F%3Ereference%3A%20XLoopHeaderCount%3A1%2F1%3C%2FP%3E%3CP%3EIt%20means%20that%20the%20message%20got%20silently%20dropped%20because%20it%20has%20reached%20datacenters%20X-MS-Exchange-Inbox-Rules-Loop%20limit%20which%20is%20(as%20described%20above)%201.%3C%2FP%3E%3CP%3EMostly%20important%20for%20Exchange%20Online%20customers%20who%20run%20an%20on-premises%20Exchange%20organization%20in%20a%20Hybrid%20configuration%3A%20we%20also%20check%20if%20current%20recipient%20mail%20address%20is%20already%20present%20within%20an%20X-MS-Exchange-Inbox-Rules-Loop%20header%20for%20incoming%20messages.%20If%20that%20is%20the%20case%2C%20then%20we%20silently%20drop%20the%20message%20as%20well%20(not%20yet%20relevant%20in%20Exchange%20Online%20because%20the%20X-MS-Exchange-Inbox-Rules-Loop%20limit%20is%20currently%201%20which%20means%20we%20drop%20the%20message%20if%20any%20X-MS-Exchange-Inbox-Rules-Loop%20header%20exists%20when%20the%20message%20arrives%2C%20regardless%20of%20which%20address%20the%20header%20contains).%3C%2FP%3EX-MS-Exchange-Transport-Rules-Loop%20header%3CP%3EWe%20set%20this%20header%20in%20the%20following%20scenario%3A%3C%2FP%3E%3CP%3EMail%20gets%20redirected%20or%20recipients%20are%20added%20(To%2C%20Cc%2C%20Bcc)%20by%20an%20Exchange%20transport%20rule%20(ETR)%3C%2FP%3E%3CP%3EIf%20the%20value%20of%20this%20header%20exceeds%20its%20thresholds%20(in%20the%20cloud%2C%20the%20number%20of%20times%20a%20message%20can%20be%20redirected%20or%20forwarded%20automatically%20by%20using%20a%20transport%20rule%20is%20limited%20to%201%20-%20please%20have%20a%20look%20at%20Scenario%202%20in%20the%20Real-life%20examples%20%E2%80%93%20what%20is%20the%20impact%20on%20email%3F%20how%20this%20can%20happen)%2C%20we%20then%20stop%20processing%2C%20drop%20the%20message%2C%20log%20the%20event%2C%20and%20finally%20send%20out%20an%20NDR%20to%20the%20original%20sender%20like%20this%3A%3C%2FP%3E%3CP%3E550%205.7.128%20TRANSPORT.RULES.RejectMessage%3B%20Transport%20rules%20loop%20count%20exceeded%20and%20message%20rejected%3C%2FP%3E%3CP%3ENote%3A%20We%20do%20not%20send%20an%20NDR%20to%20the%20original%20sender%20for%20any%20recipient%20added%20to%20Bcc%20by%20an%20Exchange%20transport%20rule%20during%20the%20mail%20flow%20(we%20only%20NDR%20for%20To%20and%20Cc%20type%20recipients).%3C%2FP%3EX-MS-Exchange-Moderation-Loop%20header%3CP%3EExample%20scenario%20when%20we%20set%20this%20header%3A%3C%2FP%3EWhen%20a%20message%20is%20forwarded%20for%20approval%2C%20we%20stamp%20this%20header%20into%20the%20approval%20message%20followed%20by%20arbitration%20mailbox%20SMTP%20address%3A%3CP%3EX-MS-Exchange-Moderation-Loop%3A%20SPO_Arbitration_fa627f00-12d2-4d68-bd5d-75cd62ead0ee%40M365x777241.onmicrosoft.com%3C%2FP%3EWe%20allow%20at%20maximum%201%20header.%20If%20there%20are%20more%20headers%20in%20place%2C%20we%20are%20going%20to%20silently%20drop%20the%20approval%20message.%3CP%3EYou%20will%20find%20the%20following%20smtp%20status%20logged%20when%20running%20a%20message%20trace%3A%3C%2FP%3E%3CP%3E550%205.2.0%20Resolver.MT.ModerationLoop%3B%20Loop%20in%20approval%20process%3C%2FP%3EX-LD-Processed%20header%3CP%3EWe%20use%20this%20header%20to%20track%20transport%20processing%20on%20a%20per%20tenant%20basis%3A%3C%2FP%3ETo%20track%20potential%20loops%20due%20to%20mail%20contact%20ExternalEmailAddress%20(TargetAddress)%20redirection%20If%20forwarding%20is%20configured%20using%20the%20Set-Mailbox%20-ForwardingSMTPAddress%20or%20-ForwardingAddress%20parameter%3CP%3EIf%20an%20action%20like%20this%20was%20detected%20from%20our%20service%2C%20we%20stamp%20the%20header%20followed%20by%20the%20ID%20of%20the%20tenant%20and%20a%20list%20of%20strings%20indicating%20the%20list%20of%20work%20that%20is%20being%20tracked.%3C%2FP%3E%3CP%3EThis%20may%20be%3A%3C%2FP%3EExtAddr%20if%20we%20are%20doing%20an%20external%20redirection%20by%20using%20ExternalEmailAddress%20ExtFwd%20if%20we%20are%20doing%20external%20forwarding%20by%20using%20ForwardingSMTPAddress%20or%20ForwardingAddress%3CP%3EIf%20the%20message%20is%20redirected%20or%20forwarded%20to%20another%20tenant%2C%20we%20add%20another%20X-LD-Processed%20header%20containing%20the%20tenants%20ID%20(we%20do%20not%20replace%20any%20existing%20X-LD-Processed%20header).%20If%20the%20message%20comes%20from%20an%20external%20address%20and%20is%20redirected%20to%20another%20external%20address%2C%20we%20also%20stamp%20the%20Resent-From%20header%20to%20indicate%20that%20Exchange%20has%20touched%20it.%3C%2FP%3E%3CP%3EWe%20allow%20a%20maximum%20of%203%20loops%20per%20tenant%20for%20ExternalEmailAddress%20(TargetAddress)%20or%20ForwardingAddress%2FForwardingSmtpAddress.%3C%2FP%3E%3CP%3EIf%20we%20exceed%20the%20number%20of%20forwards%2C%20we%20track%20the%20following%20smtp%20event%20(you%20can%20find%20the%20event%20by%20running%20a%20message%20trace).%20We%20do%20not%20send%20out%20an%20NDR%20to%20prevent%20further%20loops%3A%3C%2FP%3E%3CP%3E550%205.4.142%20RESOLVER.FWD.LoopingTarget%3B%20forwarding%20to%20a%20looping%20external%20address%3C%2FP%3E%3CP%3EWe%20also%20detect%20if%20there%20is%20a%20loop%20within%20the%20directory.%20You%20normally%20should%20not%20run%20into%20this%20kind%20of%20loop.%20It%20can%20occur%2C%20for%20example%2C%20when%20a%20mailbox%20has%20forwarding%20configured%20and%20ForwardingAddress%20refers%20to%20itself.%20This%20job%20is%20done%20while%20the%20message%20is%20processed.%20If%20we%20detect%20a%20loop%20here%2C%20the%20message%20will%20be%20dropped%20and%20we%20NDR%20the%20sender%20with%3A%3C%2FP%3E%3CP%3E550%205.4.6%20RESOLVER.FWD.Loop%3B%20there%20is%20a%20forwarding%20loop%20configured%20in%20the%20directory%3C%2FP%3EX-MS-Exchange-ForwardingLoop%20header%3CP%3EThis%20header%20is%20added%20when%20forwarding%20happens%20due%20to%20ForwardingSmtpAddress%20or%20ForwardingAddress%20properties%20set%20on%20a%20mailbox.%20In%20the%20case%20where%20the%20mailbox%20also%20has%20DeliverToMailboxAndForward%3A%24true%2C%20when%20recipient%20A%20forwards%20a%20message%20to%20recipient%20B%2C%20there%20will%20be%20two%20copies%20of%20the%20message.%20One%20to%20the%20original%20recipient%20A%20and%20the%20other%20to%20the%20forwarded%20recipient%20B.%20The%20value%20of%20the%20header%20in%20the%20message%20to%20the%20forwarded%20recipient%20B%20will%20contain%20%3CSMTPADDRESSOFORIGINALRECIPIENT%3E%3B%3CTENANTGUIDOFORIGINALRECIPIENT%3E.%20The%20header%20looks%20like%20this%3A%3C%2FTENANTGUIDOFORIGINALRECIPIENT%3E%3C%2FSMTPADDRESSOFORIGINALRECIPIENT%3E%3C%2FP%3E%3CP%3EX-MS-Exchange-ForwardingLoop%3A%20JDoe%40contoso.com%3B53bb1ab7-edea-4e35-8c3f-e395807764bf%3C%2FP%3E%3CP%3EThe%20purpose%20of%20this%20header%20is%20to%20detect%20forwarding%20loops%20like%20A%20forwards%20to%20B%20and%20B%20forwards%20to%20A.%26nbsp%3B%20If%20B%20attempts%20to%20forward%20to%20A%2C%20the%20message%20will%20be%20dropped%20with%20the%20smtp%20response%3A%3C%2FP%3E%3CP%3E550%205.4.142%20RESOLVER.FWD.LoopingTarget%3B%20forwarding%20to%20a%20looping%20external%20address%3C%2FP%3E%3CP%3EThe%20message%20copy%20to%20the%20original%20recipient%20A%20will%20also%20have%20this%20header%20added%20with%20the%20value%20ForwardingHandled%3B%26lt%3B%20TenantGuidOfOriginalRecipient%26gt%3B.%20It%20looks%20like%20this%20one%3A%3C%2FP%3E%3CP%3EX-MS-Exchange-ForwardingLoop%3A%20ForwardingHandled%3B53bb1ab7-edea-4e35-8c3f-e395807764bf%3C%2FP%3E%3CP%3EThe%20purpose%20of%20this%20header%20with%20ForwardingHandled%20value%20is%20to%20prevent%20forwarding%20message%20multiple%20times%20in%20scenarios%20like%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fexchange%2Ftransport-options%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3ECentralized%20Mail%20Transport%3C%2FA%3E%20(aka%20CMT%20or%20CMC)%2C%20where%20the%20message%20to%20the%20original%20recipient%20is%20routed%20out%20of%20the%20service%20and%20then%20back%20to%20the%20service.%20In%20a%20CMC%20scenario%20the%20message%20will%20be%20forwarded%20first%20when%20the%20message%20enters%20the%20service.%20When%20the%20message%20gets%20routed%20out%20and%20sent%20back%20to%20the%20service%2C%20duplicate%20forwarding%20will%20be%20prevented%20by%20looking%20at%20this%20header%20in%20the%20message.%20Please%20have%20a%20look%20at%20Scenario%205%20at%20the%20end%20of%20this%20post%20to%20get%20a%20better%20understanding%20of%20the%20workflow%20in%20CMC%20scenario.%3C%2FP%3E%3CP%3ENote%3A%20Customers%20sometimes%20make%20use%20of%20the%20X-MS-Exchange-Inbox-Rules-Loop%20header%20to%20check%20if%20a%20message%20was%20forwarded%20to%20forwarding%20address%20or%20forwarding%20SMTP%20address%20of%20the%20mailbox.%20If%20you%20are%20doing%20so%2C%20you%20should%20now%20use%20the%20new%20X-MS-Exchange-ForwardingLoop%20header%20instead.%3C%2FP%3EX-MS-Exchange-Generated-Message-Source%20header%3CP%3EThis%20header%20is%20used%20to%20check%20for%20loops%20in%20Exchange%20agent-generated%20messages.%20In%20Exchange%20Online%2C%20we%20do%20this%20while%20they%20are%20in%20submission%20and%20smtp%20process.%20We%20make%20use%20of%20this%20header%20for%20example%20if%20an%20automatic%20reply%20via%20inbox%20rule%20is%20in%20place.%20We%20then%20stamp%20the%20following%20headers%3A%3C%2FP%3E%3CP%3EX-Auto-Response-Suppress%3A%20All%3CBR%20%2F%3EX-MS-Exchange-Inbox-Rules-Loop%3A%20%3CA%20href%3D%22mailto%3Ajohn.doe%40contoso.com%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3Ejohn.doe%40contoso.com%3C%2FA%3E%3CBR%20%2F%3Eauto-submitted%3A%20auto-generated%3CBR%20%2F%3EX-MS-Exchange-Generated-Message-Source%3A%20Mailbox%20Rules%20Agent%3C%2FP%3E%3CP%3ELet%20us%20have%20a%20closer%20look%20at%20these%20X-headers%3A%3C%2FP%3EX-Auto-Response-Suppress%20Specifies%20whether%20a%20client%20or%20server%20application%20will%20forego%20sending%20automated%20replies%20in%20response%20to%20this%20message.%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fopenspecs%2Fexchange_server_protocols%2Fms-oxcmail%2Fced68690-498a-4567-9d14-5c01f974d8b1%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3EThere%20are%20different%20values%20available%3C%2FA%3E.%20In%20case%20of%20an%20automatic%20reply%2C%20Exchange%20sets%20the%20value%20to%20All.%20X-MS-Exchange-Inbox-Rules-Loop%20Please%20have%20a%20look%20at%201)%20X-MS-Exchange-Inbox-Rules-Loop%20auto-submitted%20Defined%20in%20%3CA%20href%3D%22https%3A%2F%2Ftools.ietf.org%2Fhtml%2Frfc3834%23section-5%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%20target%3D%22_blank%22%3ERFC%203834%3C%2FA%3E.%20Let%20me%20quote%20from%20there%3A%3CP%3E%E2%80%9CThe%20purpose%20of%20the%20Auto-Submitted%20header%20field%20is%20to%20indicate%20that%20the%20message%20was%20originated%20by%20an%20automatic%20process%2C%20or%20an%20automatic%20responder%2C%20rather%20than%20by%20a%20human%3B%20and%20to%20facilitate%20automatic%20filtering%20of%20messages%20from%20signal%20paths%20for%20which%20automatically%20generated%20messages%20and%20automatic%20responses%20are%20not%20desirable.%E2%80%9D%3C%2FP%3EX-MS-Exchange-Generated-Message-Source%20Short%3A%20This%20X-header%20is%20used%20to%20prevent%20mail%20loops%20caused%20by%20agent-generated%20messages.%20Long%3A%20If%20this%20header%20is%20present%2C%20it%20means%20that%20the%20mail%20you%20see%20is%20an%20agent-generated%20message.%20We%20check%20if%20it%20does%20not%20exceed%20our%20limits.%20We%20do%20these%20checks%20while%20the%20message%20is%20processed%20in%20submission%20and%20smtp.%20There%20are%20different%20limits%20in%20place.%20If%20the%20message%20is%20an%20inter-tenant%20one%20(means%20no%20intra-tenant%20organization%20header%20exists)%2C%20we%20limit%20this%20to%203%20agents%2C%20and%20they%20may%20be%20the%20same%20(for%20example%20three%20times%20DLP%20Policy%20Agent).%3CP%3EYou%20will%20see%20multiple%20agents%20for%20example%20if%20you%20have%20DLP%20in%20place%20and%20an%20inbox%20rule%20which%20redirects%20every%20message%20to%20another%20mailbox.%20If%20your%20DLP%20policy%20matches%20and%20you%20receive%20a%20mail%20notification%20that%20gets%20redirected%20to%20another%20mailbox%2C%20you%20will%20see%20something%20like%20this%3A%3C%2FP%3E%3CP%3EX-MS-Exchange-Generated-Message-Source%3A%20DLP%20Policy%20Agent%2CMailbox%20Rules%20Agent.%3C%2FP%3E%3CP%3EIf%20the%20message%20is%20an%20intra-tenant%20one%2C%20we%20limit%20this%20to%20a%20maximum%20of%202%20Exchange%20agents.%20Side%20effect%20messages%20are%2C%20for%20example%2C%20intra-tenant%20messages.%20This%20kind%20of%20messages%20are%20generated%20after%20a%20message%20has%20been%20delivered%20to%20the%20mailbox.%20For%20example%2C%20a%20message%20delivered%20to%20a%20mailbox%20triggers%20an%20auto%20reply%20or%20inbox%20rule%20that%20redirects%20the%20message%20to%20another%20recipient.%20In%20this%20case%2C%20a%20side%20effect%20message%20is%20generated.%20We%20drop%20the%20message%20if%20the%20Exchange%20agent%20is%20the%20same%20(for%20example%20two%20times%20DLP%20Policy%20Agent).%20While%20in%20progress%2C%20side%20effect%20messages%20are%20stamped%20with%20the%20following%20header%20which%20is%20replaced%20after%20the%20message%20has%20been%20delivered.%3C%2FP%3E%3CP%3EX-MS-Exchange-Organization-Generated-Message-Source%3A%20Mailbox%20Rules%20Agent%3C%2FP%3ESome%20more%20loop%20protection%20insights%3CP%3EWe%20also%20detect%20incoming%20messages%20that%20are%20looping%20when%20they%20pass%20Exchange%20Online%20Protection%20(EOP).%20We%20count%20every%20time%20a%20message%20passes%20through%20EOP%20frontdoor%20and%20we%20reject%20every%20message%20that%20reaches%20our%20thresholds.%20Let%20me%20explain%20this%20in%20a%20little%20more%20detail.%3C%2FP%3E%3CP%3ETo%20do%20this%2C%20we%20need%20some%20more%20headers.%20As%20this%20is%20EOP%20related%20work%2C%20the%20headers%20are%20named%20like%20this%3A%3C%2FP%3EX-EOPAttributedMessage%20X-EOPTenantAttributedMessage%20Some%20more%20internal%20loop%20prevention%20headers%20for%20routing%20to%20quarantine%20and%20ATP%3CP%3EWe%20increase%20the%20X-EOPAttributedMessage%20header%20every%20time%20the%20message%20is%20processed%20by%20EOP%20frontdoor.%20It%20looks%20like%20this%3A%3C%2FP%3E%3CP%3EX-EOPAttributedMessage%3A%201%3C%2FP%3E%3CP%3EWe%20also%20stamp%20the%20X-EOPTenantAttributedMessage%20header%20with%20tenant%20guid%20and%20a%20number%20which%20shows%20how%20often%20the%20message%20was%20processed%20through%20this%20tenants%20EOP.%20A%20valid%20header%20of%20a%20messages%20that%20passes%20EOP%20for%20the%20first%20time%20looks%20like%20this%3A%3C%2FP%3E%3CP%3EX-EOPTenantAttributedMessage%3A%20543b1ab7-eeea-4a35-8c3f-e396007764bf%3A0%3C%2FP%3E%3CP%3EIf%20the%20message%20is%20re-routed%20through%20another%20tenant%20(for%20example%2C%20an%20ETR%20in%20Tenant%20A%20automatically%20forwards%20the%20message%20to%20Tenant%20B)%2C%20the%20X-EOPTenantAttributedMessage%20header%20is%20reset.%20Anyway%2C%20the%20X-EOPAttributedMessage%20count%20is%20kept%20and%20increased.%20We%20drop%20the%20message%20if%20it%20goes%20several%20times%20through%20the%20same%20tenant%20(X-EOPTenantAttributedMessage)%20or%20when%20it%20exceeds%20a%20threshold%20of%20several%20more%20message%20being%20routed%20between%20different%20tenants).%3C%2FP%3E%3CP%3EIf%20we%20exceed%20the%20number%20of%20total%20hops%20(which%20is%20currently%207%20but%20it%20but%20can%20be%20changed%20in%20the%20future%20without%20being%20separate%20announced)%2C%20you%20can%20find%20the%20following%20smtp%20response%20logged%3A%3C%2FP%3E%3CP%3E554%205.4.14%20Hop%20count%20exceeded%20-%20possible%20mail%20loop%20ATTR1%3C%2FP%3E%3CP%3EIf%20we%20exceed%20the%20hop%20count%20within%20the%20same%20tenant%20(which%20is%20currently%203%20but%20can%20be%20changed%20in%20the%20future%20without%20separate%20announcement)%2C%20we%20then%20NDR%20this%20one%20out%3A%3C%2FP%3E%3CP%3E554%205.4.14%20Hop%20count%20exceeded%20-%20possible%20mail%20loop%20ATTR34%3C%2FP%3E%3CP%3EIf%20you%20see%20any%20of%20the%20following%20smtp%20responses%20logged%2C%20you%20then%20should%20be%20open%20a%20support%20case%20for%20further%20investigation.%20We%20protocol%20these%20if%20a%20threshold%20associated%20with%20quarantine%20or%20ATP%20has%20been%20reached%20and%20a%20message%20has%20been%20dropped%20by%20the%20service%3A%3C%2FP%3E%3CP%3E454%204.4.15%20Hop%20count%20exceeded%20-%20possible%20mail%20loop%20ATTR39%3C%2FP%3E%3CP%3E454%204.4.15%20Hop%20count%20exceeded%20-%20possible%20mail%20loop%20ATTR40%3C%2FP%3EReal-life%20examples%20%E2%80%93%20what%20is%20the%20impact%20on%20email%3F%3CP%3EHere%20are%20some%20examples%20of%20how%20all%20of%20this%20may%20affect%20your%20mail%20flow%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EScenario%201%3A%3C%2FP%3E%3CP%3EJohn%20Doe%20(Contoso%20Ltd.)%20creates%20an%20inbox%20rule%20to%20redirect%20every%20message%20to%20Mike%20Meyer%20(TailSpin%20Toys).%20Mike%20in%20turn%20has%20another%20inbox%20rule%20in%20place%20to%20redirect%20every%20incoming%20message%20to%20Anna%20Smith%20(Fabrikam%2C%20Inc.).%3C%2FP%3E%3CP%3EResult%3A%3C%2FP%3E%3CP%3EIn%20this%20case%2C%20Exchange%20stamps%20the%20X-MS-Exchange-Inbox-Rules-Loop%3A%20John.Doe%40contoso.com%20header%20after%20the%20first%20redirect%20is%20processed.%20Exchange%20at%20TailSpin%20Toys%20detects%20that%20header%20(message%20tracking%20reference%20will%20log%20XLoopHeaderCount%3A1%2F1)%20and%20does%20not%20redirect%20the%20message%20again.%20In%20this%20case%20Mike%20Meyer%20will%20not%20get%20an%20NDR.%20As%20an%20administrator%20you%20will%20find%20this%20event%20by%20running%20a%20message%20trace.%3C%2FP%3E%3CP%3EThis%20scenario%20is%20one%20of%20the%20most%20seen%20and%20we%20must%20be%20very%20restrictive%20because%20customers%20can%20easily%20build%20a%20loop%20here.%20Therefore%2C%20we%20restrict%20this%20to%20only%201%20redirect%2Fforward%20by%20using%20inbox%20rules.%20This%20limit%20is%20hardcoded%20and%20cannot%20be%20changed.%20If%20you%20make%20use%20of%20Exchange%20on-premises%2C%20it%20is%20possible%20to%20have%20up%20to%203%20redirects%20by%20inbox%20rules%20in%20place.%20As%20an%20administrator%20it%20is%20your%20task%20to%20protect%20your%20users%20from%20building%20loops.%26nbsp%3B%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EScenario%202%3A%3C%2FP%3E%3CP%3EIn%20this%20scenario%20we%20make%20use%20of%20two%20transport%20rules.%20The%20first%20one%2C%20located%20at%20Contoso%E2%80%99s%20Exchange%20organization%2C%20redirects%20every%20message%20addressed%20to%20John.Doe%40contoso.com%20and%20coming%20from%20outside%20the%20organization%2C%20to%20Mike%20Meyer%20at%20TailSpin%20Toys%20company%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EAt%20TailSpin%20Toys%20there%20is%20also%20a%20transport%20rule%20in%20place%2C%20to%20Bcc%20incoming%20messages%20to%20Anna%20Smith%20at%20Fabrikam%3A%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EResult%3A%3C%2FP%3E%3CP%3EIn%20this%20case%20the%20message%20is%20stamped%20at%20transport%20within%20Contoso%20organization.%20We%20see%20the%20X-MS-Exchange-Transport-Rules-Loop%3A%201%20header.%20At%20TailSpin%20Toys%20the%20message%20is%20dropped%20due%20to%20X-MS-Exchange-Transport-Rules-Loop%3A%201%20header.%20If%20you%20run%20a%20message%20trace%2C%20you%20will%20find%20the%20following%20event%20logged%3A%3C%2FP%3E%3CP%3E550%205.7.128%20TRANSPORT.RULES.RejectMessage%3B%20Transport%20rules%20loop%20count%20exceeded%20and%20message%20rejected%3C%2FP%3E%3CP%3ERemember%3A%20We%20do%20not%20send%20out%20an%20NDR%20to%20the%20original%20sender.%20This%20is%20because%20of%20the%20second%20transport%20rule%20which%20is%20configured%20to%20add%20an%20additional%20recipient%20as%20BCC%20into%20the%20message.%20If%20the%20second%20transport%20rule%20is%20configured%20to%20add%20an%20CC-Recipient%20or%20simply%20redirects%20the%20message%20instead%20of%20an%20additional%20recipient%20as%20BCC%2C%20an%20NDR%20will%20be%20send%20out%20to%20the%20original%20sender.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EScenario%203%3A%3C%2FP%3E%3CP%3EIn%20this%20scenario%20we%20are%20going%20to%20have%20a%20look%20at%20the%20moderation%20loop%20protection.%20We%20have%20a%20transport%20rule%20(2)%20that%20forwards%20every%20message%2C%20send%20from%20outside%20the%20organization%20to%20shared%40fabrikam.com%2C%20to%20Anna%20Smith%20for%20approval%20(3).%20Anna%20is%20going%20to%20holiday%20and%20so%20she%20has%20created%20an%20inbox%20rule%20to%20redirect%20every%20message%20to%20the%20marketing%20team%20(4).%20Unfortunately%2C%20the%20marketing%20distribution%20list%20is%20also%20moderated.%3C%2FP%3E%3CP%3EResult%3A%3C%2FP%3E%3CP%3EIn%20this%20case%2C%20the%20moderation%20message%20is%20stamped%20with%20the%20X-MS-Exchange-Moderation-Loop%20header%2C%20followed%20by%20the%20smtp%20address%20of%20the%20arbitration%20mailbox%3A%3C%2FP%3E%3CP%3EX-MS-Exchange-Moderation-Loop%3A%20SPO_Arbitration_fa627f00-12d2-4d68-bd5d-75cd62ead0ee%40M365x777241.onmicrosoft.com%3C%2FP%3E%3CP%3EThe%20approval%20request%20which%20is%20forwarded%20via%20inbox%20rule%20from%20Anna%E2%80%99s%20mailbox%20to%20the%20marketing%20distribution%20list%20is%20dropped%20and%20no%20NDR%20is%20send%20out%20to%20the%20original%20sender.%20If%20you%20run%20a%20message%20trace%2C%20you%20will%20find%20the%20following%20smtp%20response%20stamped%3A%3C%2FP%3E%3CP%3E550%205.2.0%20Resolver.MT.ModerationLoop%3B%20Loop%20in%20approval%20process%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EScenario%204%3A%3C%2FP%3E%3CP%3EIn%20this%20scenario%20we%20are%20going%20to%20have%20a%20look%20at%20the%20X-LD-Processed%20header%20and%20how%20it%20works.%20Assumed%20we%20have%20the%20following%20setup%3A%20We%20have%20two%20companies%20%E2%80%93%20TailSpin%20Toys%20and%20Fabrikam.%20Both%20have%20marketing%20departments%20working%20together.%20To%20make%20this%20workflow%20easier%2C%20they%20decide%20to%20create%20mail%20users%20for%20each%20other%20company%20department%20(Marketing-Fabrikam%20and%20Marketing-TailSpin).%20Unfortunately%2C%20someone%20added%20the%20mail%20users%20to%20the%20local%20marketing%20distribution%20list%20%E2%80%93%20and%20the%20loop%20begins.%3C%2FP%3E%3CP%3EResult%3A%3C%2FP%3E%3CP%3EWhat%20happens%20here%3F%20Someone%20sends%20a%20mail%20to%20one%20of%20the%20distribution%20lists.%20Exchange%20expands%20the%20list%20and%20starts%20processing%20the%20item.%20For%20the%20first%20time%20the%20mail%20gets%20processed%2C%20we%20check%20on%20transport%20if%20any%20X-LD-Processed%20header%20followed%20by%20tenants%20guid%20is%20present.%20If%20this%20is%20not%20the%20case%2C%20we%20stamp%20a%20header%20like%20this%3A%3C%2FP%3E%3CP%3EX-LD-Processed%3A%206249f43a-676b-4124-a13a-50205140b751%2CExtAddr%3C%2FP%3E%3CP%3EWe%20do%20this%20also%20for%20the%20other%20tenant.%20So%20one%20more%20X-LD-Processed%20header%20is%20added%3A%3C%2FP%3E%3CP%3EX-LD-Processed%3A%2053bb1ab7-edea-4e35-8c3f-e395807764bf%2CExtAddr%3C%2FP%3E%3CP%3EWe%20keep%20doing%20this%20every%20time%20the%20message%20is%20processed%20and%20at%20the%20end%20(after%20the%20message%20was%20processed%20for%20the%203rd%20time)%2C%20the%20header%20looks%20like%20this%3A%3C%2FP%3E%3CP%3EX-LD-Processed%3A%206249f43a-676b-4124-a13a-50205140b751%2CExtAddr%2CExtAddr%2CExtAddr%3C%2FP%3E%3CP%3EX-LD-Processed%3A%2053bb1ab7-edea-4e35-8c3f-e395807764bf%2CExtAddr%2CExtAddr%2CExtAddr%3C%2FP%3E%3CP%3EIf%20the%20message%20enters%20transport%20again%2C%20it%20will%20be%20dropped%20and%20NDR%20is%20send%20out%20to%20the%20original%20sender%3A%3C%2FP%3E%3CP%3E554%205.4.14%20Hop%20count%20exceeded%20-%20possible%20mail%20loop%20ATTR1%20%5BHE1EUR04FT048.eop-eur04.prod.protection.outlook.com%5D%3C%2FP%3E%3CP%3EAnd%20so%2C%20the%20loop%20ends.%3C%2FP%3E%3CP%3E%3C%2FP%3E%3CP%3EScenario%205%3A%3C%2FP%3E%3CP%3EIn%20this%20scenario%20we%20are%20going%20to%20have%20a%20look%20at%20the%20X-MS-Exchange-ForwardingLoop%20header%20and%20how%20it%20works.%20Assumed%20we%20have%20the%20following%20setup%3A%20Fabrikam%20has%20a%20Hybrid%20configuration%20and%20have%20also%20enabled%20Centralized%20Mail%20Transport%20(CMT%3B%20also%20known%20as%20CMC%2C%20RouteAllMessagesViaOnPremises%20enabled%20on%20the%20outbound%20connector).%20MX%20points%20to%20the%20Exchange%20Online%20service%20to%20make%20use%20of%20our%20malware%20and%20spam%20protection%20features.%20They%20need%20to%20route%20all%20outgoing%20messages%20through%20Exchange%20on-premises%20because%20of%20their%20mail%20signature%20and%20DLP%20solution%20which%20has%20not%20been%20migrated%20to%20cloud%20yet.%20Anna%20Smith%20of%20Fabrikam%20has%20set%20ForwardingSmtpAddress%20to%20John.Doe%40contoso.com%20as%20well%20as%20DeliverToMailboxAndForward%20set%20to%20%24true.%3C%2FP%3E%3CP%3EResult%3A%3C%2FP%3E%3CP%3EA%20message%20addressed%20to%20Anna.Smith%40fabrikam.com%20enters%20the%20service%20(1).%20We%20notice%20that%20ForwardingSmtpAddress%20is%20set%20to%20John.Doe%40contoso.com%20as%20well%20as%20DeliverToMailboxAndForward%20is%20set%20to%20%24true.%20Now%20message%20bifurcation%20kicks%20in%20and%20creates%20another%20copy%20of%20the%20message.%20The%20message%20which%20goes%20to%20John.Doe%40contoso.com%20gets%20stamped%20(2a)%20with%20following%20header%3A%3C%2FP%3E%3CP%3EX-MS-Exchange-ForwardingLoop%3A%20Anna.Smith%40fabrikam.com%3B53bb1ab7-edea-4e35-8c3f-e395807764bf%3C%2FP%3E%3CP%3EAnd%20is%20routed%20through%20Exchange%20on-premises%20to%20John.Doe%40contoso.com.%20Unfortunately%2C%20there%20is%20also%20ForwardingSmtpAddress%20set%20on%20John%20Doe%E2%80%99s%20mailbox%20which%20points%20to%20Anna.Smith%40fabrikam.com.%20The%20message%20is%20now%20routed%20to%20the%20Exchange%20Online%20service%20again%20(3a).%20Here%20we%20detect%20that%20X-MS-Exchange-ForwardingLoop%20has%20already%20been%20set%20with%20that%20recipient%20and%20tenant%20guid.%20Result%20of%20this%20is%20that%20we%20drop%20the%20message%20with%20smtp%20response%3A%3C%2FP%3E%3CP%3E550%205.4.142%20RESOLVER.FWD.LoopingTarget%3B%20forwarding%20to%20a%20looping%20external%20address%3C%2FP%3E%3CP%3EThe%20original%20message%20copy%20to%20Anna%20Smith%E2%80%99s%20mailbox%20is%20also%20on%20its%20way.%20This%20message%20also%20makes%20an%20extra%20round%20through%20Exchange%20on-premises%20due%20to%20requirement%20imposed%20by%20having%20CMC%20enabled%20and%20it%E2%80%99s%20coming%20from%20Internet%20(i.e.%20not%20having%20passed%20through%20on-premises%20yet).%20Before%20being%20sent%20to%20on-premises%2C%20however%2C%20this%20copy%20was%20stamped%20with%20a%20header%20(2b).%20It%20looks%20a%20little%20different%20to%20the%20header%20mentioned%20before%3A%3C%2FP%3E%3CP%3EX-MS-Exchange-ForwardingLoop%3A%20ForwardingHandled%3B53bb1ab7-edea-4e35-8c3f-e395807764bf%3C%2FP%3E%3CP%3EAs%20you%20can%20see%2C%20it%20contains%20ForwardingHandled%20instead%20of%20the%20recipient%E2%80%99s%20e-mail%20address.%20We%20need%20to%20do%20this%20in%20order%20to%20remember%20that%20Forwarding%20was%20already%20applied%20in%20cases%20when%20the%20message%20then%20has%20a%20routing%20requirement%20out%20of%20the%20EXO%20service%20such%20as%20Centralized%20Mail%20Transport.%20When%20on-premises%20sends%20it%20back%20to%20Exchange%20Online%20(3b)%2C%20we%20now%20figure%20out%20that%20the%20X-MS-Exchange-ForwardingLoop%20header%20has%20already%20been%20stamped%20with%20ForwardingHandled%20flag.%20Result%20of%20this%20is%20that%20we%20don%E2%80%99t%20forward%20the%20message%20again%20(no%20RESOLVER%20REDIRECT%20event%20in%20Message%20Tracking%20Log%2FMessage%20Trace%20Details%20Report).%20The%20message%20is%20finally%20delivered%20to%20Anna%20Smith%E2%80%99s%20mailbox%20(4b).%3C%2FP%3EWhat%20if%20I%20need%20to%20do%20multiple%20forwards%20or%20redirects%20for%20handling%20business%20processes%3F%3CP%3EGlad%20you%20asked!%20Basically%2C%20there%20are%203%20ways%20to%20go%3A%3C%2FP%3EKeep%20these%20mailboxes%20on-premises%20(which%20is%20not%20a%20real%20option%20if%20you%20want%20to%20use%20the%20awesome%20features%20available%20in%20Exchange%20Online).%20Remember%3A%20Some%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Foffice365%2Fservicedescriptions%2Fexchange-online-service-description%2Fexchange-online-limits%23journal-transport-and-inbox-rule-limits%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3Elimits%3C%2FA%3E%20are%20different%20when%20using%20Exchange%20on-premises.%20Configure%20redirect%20via%20Set-Mailbox%20-ForwardingSMTPAddress%20or%20-ForwardingAddress%20parameter.%20As%20described%20above%2C%20we%20make%20use%20of%20the%20X-LD-Processed%20header%20in%20this%20scenario%20which%20allows%20up%20to%203%20redirects%20per%20tenant.%20Make%20use%20of%20%3CA%20href%3D%22https%3A%2F%2Fflow.microsoft.com%2Fen-us%2F%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3EMicrosoft%20Power%20Automate.%3C%2FA%3E%26nbsp%3BWith%20Power%20Automate%20you%20can%20create%20automated%20workflows%20between%20your%20favorite%20apps%20and%20services%20in%20a%20centralized%20way.%20This%20includes%20many%20email%20actions%20when%20using%20the%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fconnectors%2Foffice365%2F%22%20rel%3D%22noopener%20noreferrer%22%20target%3D%22_blank%22%3EMicrosoft%20365%20Outlook%20Connector%3C%2FA%3E.%20I%20encourage%20you%20to%20check%20out%20the%20documentation%2C%20give%20it%20a%20try%20and%20see%20the%20power%20of%20this%20Microsoft%20Power%20Platform%20application.%3CP%3E%3C%2FP%3E%3CP%3EI%20hope%20all%20these%20insights%20help%20you%20to%20get%20a%20better%20overview%20and%20understanding%20of%20how%20we%20handle%20possible%20loop%20situations%20in%20Exchange%20Online.%20It%20is%20sometimes%20a%20little%20confusing%20and%20may%20look%20complicated%2C%20but%20keeping%20the%20service%20running%20for%20our%20customers%20is%20a%20must.%3C%2FP%3E%3CP%3ESpecial%20thanks%20to%20all%20contributors%3A%20Especially%20to%20Stan%20Aleksiev%20for%20taking%20care%20of%20the%20technical%20review%2C%20Arindam%20Thokder%2C%20Dan%20Li%2C%20Guru%20Prasad%2C%20Arnold%20Kermer%20and%20Dmitry%20Starostin!%3C%2FP%3E%3CP%3ELukas%20Sassl%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-2312258%22%20slang%3D%22en-US%22%3E%3CP%3EWith%20this%20blog%20post%20we%20will%20give%20you%20an%20overview%20of%20how%20we%20handle%20possible%20mail%20loop%20scenarios%20in%20Exchange%20Online%20and%20how%20this%20affects%20your%20mail%20flow.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2312258%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExchange%20Online%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3ETips%20'n%20Tricks%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3Etransport%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Apr 30 2021 01:26 PM
Updated by: