Exchange Server Mail flow rule

Sometimes we want to reject Exchange mail sender according to a certain criteria. Suppose you want to block all e-mails addressed to a particular domain. This is easily done in Exchange admin center. Create a new Exchange Server Mail flow rule, as shown below:

Exchange rule

After selecting the sender and recipient domain, you have three options:

”Reject the message with the explanation”, where you can enter a short message why message was rejected

‘’Delete the message without notifying anyone’’

‘’Reject the message with the enhanced status code’’, where you must enter so called NDR (Non-delivery reports) code.

NDRs are system messages that report the delivery status of a message to the sender. NDRs are generated when a message cannot be delivered. If the computer can detect the reason for the failed delivery, it maps the reason onto a status code, and a corresponding error message is printed. For NDRs, most numeric error codes are reported in the form of “5.X.X” and are described as permanent failures.

More about NDRs:

In Exchange on-premises server you can use PowerShell cmdlet

Get-SystemMessage to view all NDRs in your organization, or use parameter

Get-SystemMessage –Original to display just embeded ones.

Any system message can be rewritten, if you are not satisfied with the original.


Get-SystemMessage En\Internal\5.7.1 Shows the original message for the 5.7.1 error code for english language

Set-SystemMessage En\Internal\5.7.1 -Text “Write here your custom message” Overwrites original message with custom message.


Setting Exchange Server Mail flow rule is easy job.

Written by Klavdij Mervic
IT teacher and system administrator for Microsoft servers like SCCM, SCOM, Sharepoint, Exchange, … in ''Solski center Nova Gorica''