Monday, July 20, 2009

Mystery of Failing Database Mail

Have you ever seen this error when you have setup database mail:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using [Account] ([TimeSent]). Exception Message: Could not connect to mail server. (No connection could be made because the target machine actively refused it

I have, and so have a few others based on my experience in the forums.  If you are like me, you immediately contacted you mail server administrator to find out why the mail server is refusing your mail.  Then once, they told you that there was nothing on the mail server that should be causing this, you tried using GMAIL/Hotmail and got the same error.  Now what do you do?  Fortunately for me I had a production server setup and working so decided to investigate differences.  Lo and behold, I found antivirus software installed on my desktop, but not on the server (let’s save that discussion for another time) So I looked in the antivirus log and, sure enough, mail being sent by database was being blocked by the “prevent mass-mailing worms” rule.  So I disabled the rule, and, viola!, mail sent successfully.  Of course the corporate antivirus policy almost immediately re-enabled the rule, but I had an answer.  I contacted my corporate antivirus administrator and had them add DatabaseMail90.exe (SQL Server 2005) to the exceptions list.

So if database mail is not working, check your antivirus settings.


  1. Coming from a proprietary world to Windows environment has been though because of lots of small little issues like the one posted in this blog.

    I was facing the very same problem and I was checking and double checking everything, but I never thought of the antivirus… until I reached this page.

    It is amazing how many are stuck configuring database mail, but after a few hours of searching for a possible root case of this problem I only managed to find this blog recommending checking for the antivirus settings.

    I really appreciate your help because I was ready to go the way of legacy mapi mail to work around this issue.

  2. Glad you found the post and that it was helpful. This is definitely a tough one to figure out. All in all Database Mail is still a major improvement over SQL Mail.

  3. does this apply to the sql server 2008 also ??
    actually i am also stuck with the same issue???
    please help me out!!

  4. Parth,

    Yes, this could happen with SQL Server 2008 Database Mail. It isn't about the SQL Server version it's about what is being restricted by the anti-virus program.

  5. Hello, this problem costed me at least 1 day of work and research. Thanks for publishing this information.

  6. Hi,
    I think you need to add your DB server in your relay server.
    There's one more Bug in DB Mailsee:

  7. Thank you. It was the antivirus in my case too!


So what do you think I am?