Create, View and Modify Custom DSN Messages in Exchange 2007 and 2010

Following up on my post about NDRs, this post describes how to work with custom DSN messages.

First, let’s talk a bit about DSN messages or Delivery Status Notifications. DSNs are system messages intended to report the delivery status of a messages back to the sender, informing him or her if and why the message fail for any reason. Delivery status notifications comes in three different types:

  • Success (2.X.X numeric codes)
  • Persistent transient failure (4.X.X numeric codes)
  • Permanent failures (5.X.X numeric codes)

When a message can not be delivered for some reason a error is reported and the server maps this error to a DSN. The 5.X.X are described as permanent failures and are the most common messages. However, you may also see 4.X.X codes from times to times .

Delivery status notifications are addressed in RFC 1891 and 1893. More detailed information on codes can be found here:

New Custom System Message

Now, on to the fun stuff! In my example, I will create a custom DSN for code 5.7.1 and enable it for external senders. I will also create a custom DSN for code 5.1.1 for internal senders. Lets start with looking at the commands…

New-SystemMessage creates a new custom system message. you will have to include the code you want to “replace” and also the message you want the DSN to include. In my example the command looks like this:

New-SystemMessage -DSNCode 5.7.1 -Text "This server does not accept relaying" -Internal $False -Language En

I also created one message for Swedish using -Language Sv.


In my second example i want my custom DSN to be sent to internal senders:

New-SystemMessage -DSNCode 5.1.1 -Text "The user does not exist, please contact the helpdesk for further assistance" -Internal $True -Language En

Again, I created a second message for Swedish as well.


And here are the result when I tried to send a messages to the non-excisting address test@sundis.local:


View Both Custom and Original System Messages

So, the message is created, now what? Well, if you want to view your new message you can use the following command:


This lists all custom system messages and note that the identity is presented in a path-like way starting with the language.


You can also list the original message that matches the newly created custom system message. If you run the following command you will list all system messages.

Get-SystemMessage –Original

To narrow it down, use where as in this example:

Get-SystemMessage -Original | where {$_.identity –eq ‘en\internal\5.7.1’}


Change a Custom System Message

If you want to change a custom system message you can do so easily using Set-SystemMessage as in this example:

Set-SystemMessage -Identity en\External\5.7.1 -Text "This server does not accept relaying, so don’t even try it!"


Remove Custom System Messages

And the last system message command that I’m going to cover is Remove-SystemMessage. In this example I will remove one of the messages I created before:

Remove-SystemMessage –Identity en\External\5.7.1


To remove all custom system messages use this command:

Get-SystemMessage | Remove-SystemMessage


I could have typed a to accept the removal of all messages instead of typing one y per message. But I wanted to show you that it removed all three messages in that single command.

One more thing…

Not that hard right? There is one more thing to consider though. Many email-servers have the habit of rewriting DSN messages to make it more user-friendly, including all Exchange servers. So even if you configure a neat DSN message for external senders they might not see it because their server applied a user friendly standard DSN.

In theory, if both servers run Exchange and they have the same version they should leave the custom DSN alone and present it to the user instead of rewriting it. I still haven’t seen this working in real life…

There is one thing you can do to prevent overwriting if you are running Exchange Server 2007 Service Pack 1 Update Rollup 4 or later. You can use the Set-TransportConfig -DSNConversionMode and the parameter comes with three different settings:

  • UseExchangeDSNs
  • PreserveDSNBody
  • DoNotConvert

UseExchangeDSNs is default and you can change it with the following command:

Set-TransportConfig –DSNConversionMode DoNotConvert


That’s all for this time, good luck with the messages. Thanks for reading and please, don’t hesitate let me know if you run in to any problems!


Configure Postmaster, Microsoft Exchange Recipient and NDR forwarding in Exchange Server 2007 and 2010

Postmaster for external messages
In Exchange 2007 and 2010 it is considered best practice to configure a postmaster address in the organization. It is also a requirement to set a postmaster for all SMTP domains according to RFC 2821:

The postmaster address is used to send system-generated messages and notifications.

To set the postmaster address use the following command:
Set-TransportConfig -ExternalPostmasterAddress <email address>

For example:
Set-TransportConfig -ExternalPostmasterAddress

Microsoft Exchange Recipient for internal messages
There is also another type of recipient configuration that you need to do if you want to be able to monitor NDRs. The Microsoft Exchange recipient is a special recipient object that can be compared to an internal postmaster. The HUB transport servers forwards internal NDRs to this recipient and not the the Postmaster.

To configure an recipient for the Microsoft Exchange recipient  use the following command:
Set-OrganizationConfig –MicrosoftExchangeRecipientReplyRecipient <String>

The String can be one of the following:

  • Distinguished name (DN)
  • Canonical name
  • GUID
  • Name
  • Display name
  • Alias
  • Exchange DN
  • Primary SMTP e-mail address

Note that if the MicrosoftExchangeRecipientReplyRecipient is not configured all messages sent to the Microsoft Exchange recipient will be discarded.

NDR forwarding
Sometimes you have the need to monitor the NDRs sent through the organization. To be able to do that you will have to configure the transport configuration to send a copy of the NDRs to a specific mailbox. Note that this affects the entire organization and not a single transport server.

Using the the GenerateCopyOfDSNFor parameter you can specify which DNS codes that will be forwarded. To save you some work, Microsoft has enabled monitoring for  the following DNSs:

  • 5.4.8
  • 5.4.6
  • 5.4.4
  • 5.2.4
  • 5.2.0
  • 5.1.4

To configure forwarding use the following command:
Set-TransportConfig -GenerateCopyOfDSNFor <DSN1, DSN2, DSN3, …>

Set-TransportConfig -GenerateCopyOfDSNFor 4.4.7,5.5.2,5.7.3

Note that the use of GenerateCopyOfDSNFor requires you to configure the Microsoft Exchange recipient and/or ExternalPostmasterAddress.