SQL Server 2008 Database Mail Failed

Had one of those ‘how weird’ moments today. We seemed to not be sending emails from a web site I look after. We’re using SQL Server 2008, and the terrifically handy Database Mail service.

I originally set this up, using instructions I found in a well explained blog post ‘Installing and Configuring Windows Server 2008 SMTP‘.

When I checked the Database Mail logs I found a bunch of errors saying:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2011-03-25T18:13:13). Exception Message: Could not connect to mail server. (No connection could be made because the target machine actively refused it 127.0.0.1:25).

Which seemed odd. So I tried a simple Telnet localhost 25, and received connection refused. Which made me wonder where the SMTP service had gone.

I checked the Features list in Server Manager, and the SMTP service was showing – so I definitely wasn’t hallucinating that I had originally installed the service (it’s not installed by default).

I tried sending a Test Mail (right click on Database Mail in SQL Server Management Studio, then used the following to check the send log and the error log:

SELECT * FROM msdb.dbo.sysmail_allitems WHERE mailitem_id = [test mail id]

SELECT * FROM msdb.dbo.sysmail_event_log WHERE mailitem_id = [test mail id]

And it showed as failed, with the same error message I’d been seeing in the logs. Then I opened IIS6.0 – the SMTP service was not showing.

Checking the logs showed the emails starting to error on a specific day. Which makes me wonder whether someone else on the team has been messing around the on the server.

I decided to try and reinstall, so I used Remove Feature in Server Manager to remove the SMTP service, then Add Feature to reinstall, and then again followed the instructions in the above blog post – which is really just about ensuring you’ve set Relaying for the localhost, so the SMTP service will accept emails from the SQL Database Mail service.

A test email went through fine. And trying functions on the web application showed emails sending fine as well.

So I have a little bit of a mystery. SQL Database Mail was all fully installed and operational. But the SMTP service seemed to have disappeared, or somehow been changed. Think I had better ask around to see who has been doing what.

 

 

 

 

One thought on “SQL Server 2008 Database Mail Failed

  1. Thank you! SMTP service was turned off. In services.msc, SMTP is listed in its non-abbreviated name: Simple Mail Transfer Protocol. It was set to manual. Restarted and presto, mail started working again. Being that I’m the only one who accessed the server – uncertain as to why it was off.

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