THE SQL Server Blog Spot on the Web

Welcome to SQLblog.com - The SQL Server blog spot on the web Sign in | |
in Search

John Paul Cook

Troubleshooting Database Mail on Windows Server 2008 and 2008 R2

Before running a bunch of diagnostic scripts on SQL Server 2005 or later to determine why database mail isn’t working, I prefer starting with functional testing of SMTP. This requires a telnet client, which is by default part of Windows Server 2003, but not Windows Server 2008 and 2008 R2. It’s easy enough to add telnet, which is an optional feature of Windows Server 2008 and 2008 R2.

image

But should you add the telnet feature? I suggest not. Best practices include having the minimum number of roles and features enabled and the fewest number of programs and applications installed on a server. Additionally, at some companies, the DBA might not have the rights to enable features or at least have been told not to enable additional features. I recommend using an open source portable telnet client. Copy it to your server and run the exe. No installation, no act of Congress to get it in place and use it. I use portable PuTTY, downloadable from here.

When you use PuTTY select Telnet and specify the correct port number.

image

Here’s my PuTTY session from a server where database mail wasn’t working (my inputs are shown in fuschia):

220 srv4.myDomain.com Microsoft ESMTP MAIL Service, Version: 7.5.7600.16544 ready at  Sun, 4 Jul 2010 12:21:47 –0500
RSET
500 5.3.3 Unrecognized command
EHLO
250-srv4.myDomain.com Hello [127.0.0.1]
250-TURN
250-SIZE 2097152
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250 OK

MAIL FROM:myUsername@myDomain.com
250 2.1.0 myUsername@myDomain.com....Sender OK

RCPT TO:myUsername@myDomain.com
550 5.7.1 Unable to relay for myUsername@myDomain.com

Notice the “Unable to relay”, which is highly diagnostic. The server has both IIS 6 and IIS 7 installed. The IIS 6 Manager is the one to use to investigate the relay problem.

 image

A check of the Relay Restrictions indicated that the local computer was no longer allowed to relay. How this became unset is unknown, but it is required. Adding the local computer back resolved the problem.

image

220 srv4.myDomain.com Microsoft ESMTP MAIL Service, Version: 7.5.7600.16544 ready at  Sun, 4 Jul 2010 13:42:05 –0500
RSET
500 5.3.3 Unrecognized command
EHLO
250-srv4.myDomain.com Hello [127.0.0.1]
250-TURN
250-SIZE 2097152
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250 OK

MAIL FROM:myUsername@myDomain.com
250 2.1.0 myUsername@myDomain.com....Sender OK

RCPT TO:myUsername@myDomain.com
250 2.1.5 myUsername@myDomain.com

I’m not sure why the initial RSET command wasn’t recognized, but as you can see, the rest of the TTY session worked just fine. See http://support.microsoft.com/kb/304897 for a complete set of commands for testing SMTP relay.

After confirming that SMTP is working, if problems still remain, you’ll need to run SQL queries to find out what is wrong. See Books Online for more information.

To help people using search engines, the original error message was: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for myUsername@myDomain.com). Notice that the 5.7.1 matches the last line from the first telnet session when the SMTP relay wasn’t properly configured.

Published Sunday, July 04, 2010 8:29 PM by John Paul Cook

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

trwalsh99 said:

good info!thanks

July 7, 2010 10:45 AM
 

Larry Leonard said:

Brilliant!  Thank you so much.

June 19, 2011 9:19 PM
 

Anand said:

Gud info John.

Just wanted to add here, there was a Bug in GUI DB Mailsetup.

http://www.sqlproblems.com/cl/91-dbmail/70-dbmail-account-creation-failed-a-bug.html

June 23, 2011 5:26 PM

Leave a Comment

(required) 
(required) 
Submit

About John Paul Cook

John Paul Cook is a Technology Solutions Professional for Microsoft's data platform and works out of Microsoft's Houston office. Prior to joining Microsoft, he was a Microsoft SQL Server MVP. He is experienced in Microsoft SQL Server and Oracle database application design, development, and implementation. He has spoken at many conferences including Microsoft TechEd and the SQL PASS Summit. He has worked in oil and gas, financial, manufacturing, and healthcare industries. John is also a Registered Nurse who graduated from Vanderbilt University with a Master of Science in Nursing Informatics and is an active member of the Sigma Theta Tau nursing honor society. He volunteers as a nurse at safety net clinics. Contributing author to SQL Server MVP Deep Dives and SQL Server MVP Deep Dives Volume 2.

This Blog

Syndication

Powered by Community Server (Commercial Edition), by Telligent Systems
  Privacy Statement