Fix Exchange SMTP Error 554 5.4.12 Hop Count Exceeded with Attachments
Question details
The user receives an SMTP 554 5.4.12 hop-count exceeded error when sending emails with attachments to a specific mail contact, whereas plain text emails without attachments deliver successfully.

- Product
- Microsoft Exchange
- Device & OS
- not provided
- Scenario
- Sending an email containing an attachment to a mail contact in a hybrid Exchange Online and on-premises Exchange Server environment.
- Observed behavior
- Messages without attachments succeed, but messages with attachments fail and return a Non-Delivery Report (NDR) indicating a routing loop (SMTP Error 554 5.4.12) between Exchange Online, the on-premises server, and a Linux server.
Retrieve the complete Non-Delivery Report (NDR) bounce message, as it contains the critical message trace headers needed to identify where the routing loop is occurring between your servers.
Analyze the NDR and Reconfigure Send Connectors
Use the Non-Delivery Report to trace the exact server path and correct any misconfigured send connectors that might be mishandling attachments.
The 554 5.4.12 hop count exceeded error occurs when an email is trapped in a routing loop, bouncing back and forth between servers until it hits a predefined limit (usually 50 hops). In hybrid environments, third-party relays or specific send connectors might route emails with attachments differently than plain text emails, inadvertently causing a loop.
Open the complete NDR message and locate the 'Received' headers. Read them from bottom to top to trace the repeated path (e.g., bouncing between Exchange Online, the On-premises Exchange server, and a Linux mail appliance).
Log into the Exchange Admin Center (EAC) for your on-premises server and navigate to 'Mail flow' > 'Send connectors'.
Check the routing configurations and smart hosts assigned to your send connectors. Ensure there are no conflicting rules that force emails with large payloads or attachments to route to an appliance that passes them right back to Exchange.
Ensure that the mail contact's ExternalEmailAddress does not point to an alias or domain that is routed internally by your on-premises server, which instantly triggers a loop.

Disable Conflicting Transport Rules
Check for mail flow transport rules that conditionally forward or redirect emails based on the presence of an attachment.
Verify Contact Properties via Exchange PowerShell
Use PowerShell to ensure the mail contact's routing address is correctly formatted and recognized as external.
Try WPS Office for Your Daily Productivity Needs
While resolving Exchange Server routing loops requires complex backend administration, your daily document management should be easy. WPS Office offers a free, lightweight, and highly compatible alternative to Microsoft Office for creating, editing, and sharing your files.

Frequently Asked Questions
What does Exchange SMTP Error 554 5.4.12 mean?
This error means 'hop count exceeded.' It occurs when an email bounces between mail servers in a continuous loop too many times (typically exceeding 50 hops) and is ultimately rejected to prevent the loop from running infinitely.
Why does the hop count error only happen when I attach files?
This happens when your Exchange environment or a third-party gateway has specific transport rules or send connectors configured to handle messages with attachments or larger sizes differently, sending them down a misconfigured routing path that creates a loop.
How can I find out where the email is looping?
You can track the loop by examining the Non-Delivery Report (NDR). Look at the 'Received' headers in the message details, reading from bottom to top, to see exactly which servers the email bounced between before failing.
Can user inbox rules cause a 554 5.4.12 error?
Yes. If a user has an inbox rule that forwards an email to another address, and that destination mailbox has a rule forwarding it back to the original sender, it creates an infinite mail loop that results in a hop count exceeded error.




