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:

http://support.microsoft.com/kb/256321/
http://support.microsoft.com/kb/284204

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.

systemmessage1

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.

systemmessage2

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

systemmessage8

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:

Get-SystemMessage

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

systemmessage3

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’}

systemmessage4

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!"

systemmessage5

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

systemmessage6

To remove all custom system messages use this command:

Get-SystemMessage | Remove-SystemMessage

systemmessage9

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

systemmessage7

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!

Advertisements

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

  1. Chris M says:

    I was trying to get custom DSN to work between 2 separate exchange servers and your note on setting the DSN to DoNotConvert fixed my problem completely. Thanks a bunch!

    • msundis says:

      First, thanks for reading and commenting Chris! And it’s great to hear that you find the post usefull, just let me know if you have any other questions!

  2. Joseph Dawson says:

    We were having a problem after switching from Exchange 2003 to 2007 where the DNS message back would no longer include the original email as an attachment. We have users internally that want that functionality. Running the DoNotConvert command seems to have resolved that for us, atleast internally. One wierd thing is when sending to an external address, it still attaches the original email, but has NO text in the body. Any ideas?

    • msundis says:

      First, thanks for reading! What updates have you installed on your Exchange Server 2007? There are some known isues that could cuse empty/blank message body and they have been fixes in different updates.

      • Joseph Dawson says:

        We are currently on Exchange 2007 SP3 with Update Rollup 1 installed.

        Again the message body is there when sent internally, but not externally. (Atleast on the few I have tested). We get a different DSN message back from the external, which may be part of the problem as well.

  3. Tom says:

    I am having trouble making this work with Exchange 2010. I followed the instructions but it still comes with the 5.7.1 being “You do not have permission to send to this recipient.”. Any thoughts?

    • msundis says:

      Hi Tom,

      First I have to apologize for the late answer! Is this issue still valid or have you solved it already?

      Best regards
      Martin

  4. Keith Stevenson says:

    Great information, 1 question. Is there a way to change the SMTP replies for given errors that would show when someone connected on port 25 to the server rather than the ones contained within emails.

    Kind Regards

    • msundis says:

      Hi Keith,

      No there’s is no way to change the behavior of Exchange transport service in that way that I know of. If you do come up with a solution please post back here, it would be interesting to hear about it

      Best regards
      Martin

      • Keith Stevenson says:

        Martin,
        Thanks for the response, I figured as much so modified our own mail server (Were a software house that writes amongst other things Mail Servers) to achieve my goal.

        Kind Regards

  5. msundis says:

    Keith,

    Great, Im glad that you where able to solve it, thanks for reading!

    Best regards
    Martin

  6. manny says:

    hello
    I tried setting up a custom dsn (giving new contact info)for external senders to a user who left but is kept active for replacement to check messages for a while. Problem is, it’s not working – it does nothing!
    What can I check to make sure I did it right? (I restarted transport service to no avail)
    -Manny
    Exch2010 by the way

    • Martin Sundström says:

      Hi Manny,

      Sorry for the late reply, does the sender get any kind of DSN back? Could it be that the receiving server rewrites your custom DSN to a standard DNS as I mention in the post?

      Martin

  7. Duncan says:

    Great article. I have set this for a customer with a transport rule that will reject any attachments. The problem I have is that the Custom DNR is not displayed if the sender is on an exchange server. It seems that the Set-TransportConfig –DSNConversionMode DoNotConvert has to be set on the server receiving the DNR. Is there anyway to force it?

  8. Sys admin says:

    Hi All,

    My HR requested to create Leaveadmin to send leave reports to users and he requested to deny replay messages I had restricted this on Right click on usermailbox – properties – mail flow settings – message delivery restrictions – only senders in the following list , if any user send email to leveadmin he is getting “”Your message can’t be delivered because delivery to this address is restricted. “” (its a default message) I want to configure custom message please help me on this

  9. JJ says:

    Hi all,

    I was wondering if it is possible to send a notification to a recipient that has been rejected an email due to limitations of incoming mail size. We speak of delivery notifications to senders but what delivery notification to receivers? Can anyone help?

    Thanks

  10. Hatim says:

    Dears, Can you please help me to get custom message for those user ,whose accounts are disable in AD and hiden in exchange,,,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: