Exchange Online Mail Flow Problems: Message Trace and NDR Analysis

Diagnose undelivered mail in Exchange Online step by step: message trace, V2 PowerShell cmdlets, common NDR codes, and connector, MX and mail flow rule errors.
Technical summary
Technology
Exchange Online, Message trace, Exchange Online PowerShell, NDR (DSN), SMTP, connector, accepted domain, MX
Topic
Diagnosing undelivered, delayed and bounced email
Level
Intermediate
Prerequisites
  • Exchange administrator or message trace rights
  • Exchange Online PowerShell module
  • Read access to the domain’s DNS records
In this article8 sections

With a “my email didn’t go out” complaint, the first question is: did the message reach Exchange Online at all? Fiddling with rules, filters or DNS without answering this wastes hours. Diagnosis starts by finding where the message stopped; message trace, Exchange Online PowerShell and non-delivery reports (NDRs) are the tools for that. Below is the order in which we break down mail flow problems. SPF, DKIM and DMARC design is out of scope; the focus is the operational diagnosis of undelivered mail.

First classification: which group the problem falls into

Before starting the diagnosis, place the problem in one of four groups. That determines which tool you look at:

Symptom Likely location First step
The sender received an NDR Exchange Online or the receiving server Read the status code in the NDR
Mail is delayed Queue, connector, receiving server “Pending” status in message trace
Mail lost, no NDR Quarantine, rule, spam folder Message trace and quarantine
No inbound mail from outside at all MX, DNS, sending side MX record and external test

Get these from the user: sender and recipient address, approximate send time (with time zone), subject line and, if there is one, the full text of the NDR. Ask for text, not a screenshot. Server names and status codes get cut off in screenshots, and the diagnostic information is lost.

Finding the message’s path with message trace

The Mail flow > Message trace section in the Exchange admin center searches by sender, recipient, message ID or delivery status within a time range. Each result shows the message status:

  • Delivered: The message was delivered to the recipient’s mailbox or an external server.
  • Failed: Delivery failed; the details show the NDR reason.
  • Pending: Delivery is being attempted or will be retried; there is usually a problem reaching the destination server.
  • Quarantined: The message was quarantined.
  • FilteredAsSpam: The message was marked as spam.
  • Expanded: Expanded to distribution group members; the members’ status is tracked separately.

The message details list events in order: RECEIVE, TRANSPORT RULE, SPAM, SEND, DELIVER, DEFER, FAIL and so on. If the mail was redirected, deleted or quarantined by a rule, the event line shows which rule or policy kicked in. For mail that shows “Delivered” but that the user can’t find, a common result is the user’s own Outlook inbox rule; it leaves no trace on the server side.

Message trace with PowerShell

For bulk queries and filtering, Exchange Online PowerShell is faster. Microsoft has replaced the old Get-MessageTrace and Get-MessageTraceDetail cmdlets with Get-MessageTraceV2 and Get-MessageTraceDetailV2; confirm which is available in your tenant with your module version. Get-MessageTraceV2 can query 90 days of data, but the start–end range in a single query can’t exceed 10 days. Split long periods into chunks.

Connect-ExchangeOnline

# Failed messages to a specific recipient in the last 2 days
Get-MessageTraceV2 -RecipientAddress "[email protected]" `
  -StartDate (Get-Date).AddDays(-2) -EndDate (Get-Date) -Status Failed |
  Select-Object Received, SenderAddress, Subject, Status, MessageTraceId

# Event details of one message
Get-MessageTraceDetailV2 -MessageTraceId "<MessageTraceId>" `
  -RecipientAddress "[email protected]" |
  Select-Object Date, Event, Action, Detail

If the user has the message, the most precise search criterion is the Message-ID header; search for it directly with the -MessageId parameter. The subject line is misleading. The same subject can repeat across dozens of messages.

Common NDR codes and what they mean

The enhanced status code (X.Y.Z) in the NDR gives the class of the problem. If the first digit is 4, it is a temporary error and is retried; if it is 5, it is permanent. Codes often seen in Exchange Online:

Code Meaning Where to look
5.1.1 / 5.1.10 Recipient not found Address spelling, recipient directory
5.1.8 Sending account blocked Restricted users, account compromise
5.2.2 Recipient mailbox full The recipient’s quota
5.4.1 Recipient address rejected Accepted domain type
5.4.6 Routing loop Forwarding, connector, hybrid
4.4.7 Message expired Destination server access, queue
5.7.1 Not authorized to deliver Group restriction, recipient policy
5.7.57 Client not authenticated SMTP settings of the application or printer
5.7.64 Tenant attribution error Inbound connector configuration
5.7.606–5.7.649 Sending IP on a block list IP reputation of the sending server

The “Diagnostic information for administrators” section at the bottom of the NDR shows the name of the server that produced the error. This is the first place to look. If the error comes from an Exchange Online server (*.prod.outlook.com or *.protection.outlook.com), the problem is in the tenant configuration; if it comes from the other side’s server, the recipient’s policy or filter is in play. The full list of codes and recommended fixes is in Microsoft’s Exchange Online NDRs and SMTP errors documentation. If you need to read the header chain of a suspicious message, our header analysis and the Received chain guide shows the way.

Connectors and hybrid mail flow errors

Connectors define mail flow between Exchange Online and your on-premises server infrastructure, partners or third-party filtering services. In hybrid Exchange environments, the Hybrid Configuration Wizard creates connectors named “Inbound from…” and “Outbound to….” Hybrid mail flow usually breaks the morning after a certificate renewal. Common problems:

  • Certificate mismatch: The inbound connector recognizes the on-premises server by the name on its TLS certificate (TlsSenderCertificateName). If the subject name of the renewed certificate changed, mail can’t be attributed to the tenant.
  • Expired certificate: When on-premises Exchange’s outbound TLS certificate expires, hybrid mail flow stops; messages wait in the on-premises queue.
  • Wrong smart host: If the outbound connector’s destination server name or IP changed, messages stay “Pending” and eventually bounce with 4.4.7.
  • Printer and application sending: If no IP-based inbound connector has been defined for multifunction printers and business applications, or if sending is done without authentication, 5.7.57 or 5.7.64 errors appear.
Get-InboundConnector | Format-List Name, Enabled, ConnectorType, SenderIPAddresses, TlsSenderCertificateName, RequireTls
Get-OutboundConnector | Format-List Name, Enabled, SmartHosts, RecipientDomains, TlsSettings, UseMXRecord

# Validate the outbound connector with a test recipient
Validate-OutboundConnector -Identity "Outbound to Branch" -Recipients "[email protected]"

The connector validation wizard in the admin center runs the same test and shows the failing step. For details of hybrid setup during migration, see our guide to Exchange Online migration methods.

Accepted domains and MX verification

The accepted domain type determines what happens to mail sent to a recipient not in the directory:

  • Authoritative: All recipients are in Exchange Online. Mail to a recipient not in the directory is rejected with code 5.4.1 by Directory-Based Edge Blocking (DBEB).
  • InternalRelay: Some recipients are on another system. Mail for recipients not in the directory is relayed to the other system through an outbound connector.

If, during a hybrid migration, there are mailboxes that stay on premises and aren’t synced to the directory, the domain must be InternalRelay. Switching to Authoritative after the migration cuts off spam to non-existent addresses at the edge. Forgetting this switch, or doing it too early, both lose mail.

Get-AcceptedDomain | Select-Object DomainName, DomainType, Default

# DNS side: check the MX record
Resolve-DnsName -Name example.com -Type MX

The MX record should point to the value shown on the domain setup page in the Microsoft 365 admin center. If a third-party filtering service has been placed in between, the MX goes to that service; in that case an inbound connector that recognizes mail from that service and, if needed, enhanced filtering for connectors should be configured in Exchange Online. For an outside view, the inbound SMTP test in Microsoft Remote Connectivity Analyzer verifies how the MX and the tenant look from the outside world.

Mail flow rules: the source of silent losses

Mail flow rules (transport rules) can redirect, reject, quarantine or silently delete a message. If a user says “no NDR, but no mail either,” a rule is the first suspect. The TRANSPORT RULE event and the rule ID appear in the message trace details.

Get-TransportRule | Sort-Object Priority |
  Select-Object Priority, Name, State, Mode, Comments
  • The priority order of rules is decisive; the “stop processing more rules” option disables the rules below.
  • A rule whose Mode is Audit or AuditAndNotify is in test mode and doesn’t apply actions; only rules in Enforce mode change the message.
  • Rules conditioned on attachment size, external recipients or keywords can conflict with exceptions business units added without telling anyone. Write a description and owner for every rule; six months later nobody remembers who added a rule or why.

Troubleshooting checklist

  • Sender, recipient, time and NDR text collected.
  • Message found in message trace; if not found, the sending side and MX were reviewed.
  • Message status and event details read; quarantine, spam or rule actions checked.
  • NDR code and the server that produced the error identified.
  • Connector certificate, IP and destination settings verified.
  • Accepted domain type and MX record checked.
  • If a permanent configuration change was made, it was recorded and verified with a test email.

Order matters. Trace first, then configuration.

For mail flow problems after a tenant merger or domain move, also review the switchover steps in our tenant-to-tenant migration plan article. For Exchange Online operations and periodic checks, see our Microsoft 365 and cloud services and technical support and scheduled maintenance pages.

Frequently asked questions

How far back do message trace results go?

Exchange Online message trace data can be queried up to 90 days back. Recent messages are shown directly in the admin center and in PowerShell; for older queries or ones with many messages, a downloadable report is used. Check Microsoft’s documentation for the current period and query limits.

What does it mean if a message doesn’t show up in message trace?

The message never reached Exchange Online. Check the sender’s server, the MX record, any filtering service in between or the sender’s own queue. The fastest route is to ask the sender for the NDR they received or their server log.

Why do you get the 550 5.4.1 Recipient address rejected error?

If the domain is defined as authoritative in Exchange Online, mail to recipients not in the directory is rejected at the edge. If the recipient really doesn’t exist, this is expected behavior. If the recipient is hosted on premises or on another system, the domain should be set to internal relay or the recipient added to the directory.

Does message trace help if mail we send lands in the other side’s spam folder?

Partly. Message trace shows that the message left Exchange Online and was delivered to the receiving server. Where the message is placed after delivery is the receiving system’s filtering decision; for that, the other side’s logs and the sending domain’s authentication configuration need to be reviewed. If the rejection happens during SPF evaluation, calculating the SPF DNS lookup limit helps weed out unnecessary include records.

Support

Contact us for support or a discovery session on this topic.

Contact form
[email protected]

Eretek System Support

Server installation, configuration, incident response and scheduled maintenance. Active Directory, virtualization and backup are managed with the same discipline.

Knowledge Center

Other articles