3

Our database mail was running for 3 years without problems, but since one week, we are often (but not always) getting this error:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2021-10-13T22:31:21). Exception Message: Cannot send mails to mail server. (Failure sending mail.). )

Unfortunately this message is not very helpful. Database mail is always trying to send the mail 2 times (with 1 minute interval), then it finally fails.

  • Is there a way to find out why exactly it is failing? ?
  • Is there a way to reconfigure database mail, so that it tries more often or sends in other ways?
5
  • 2
  • You could also get with your Mail administrator and be sure that the server attempting to send emails to the mail server has the appropriate permissions to do so.
    – rvsc48
    Oct 14, 2021 at 14:33
  • @rvsc48 It's not always failing, some mails are sent successfully. I've edited the question.
    – askolotl
    Oct 14, 2021 at 19:25
  • which SMTP server your database server is using ? is it on the same machine as database server, or on some another server ? Oct 20, 2021 at 12:35
  • 1
    Since there is a decent chance you might be running into TLS issues, especially given the timing of when your issue started (Microsoft made a change in September of this year), and the fact that it's intermittent (Microsoft is intermittently blocking outdated TLS requests), you may find my answer on this StackOverflow question helpful in resolving your issue. When I get a chance I'll convert this comment into a more detailed answer here, but hopefully that points you in the right direction. I experienced the same timing and intermittency too.
    – J.D.
    Oct 28, 2021 at 16:47

2 Answers 2

4

I discovered this week that we have been having the same problem. It started really around 10/1 and had been on and off, but not serious enough to come to my attention. This week, though, it had gotten much more severe. Yesterday I couldn't get a single email out from any of our 3 DBs, all routing through SMTP at Office 365. You don't mention your SMTP, so this may or may not be the issue for you.

Doing some digging, the one fix I could find that I believe addresses this issue is here: https://dba.stackexchange.com/a/233249/131993

Once we used that registry executable on the machine with SQL Server I was able to reliably send email on the first try. I sent around 150 messages after that fix with no issues. Because it's intermittent, I can't say with 100% certainty the issue is fixed, but so far it looks good.

1
  • The link provided solved the issue for us. The issue indeed had gotten more severe recently and we were trying to understand what the problem was. The success/fail cases appeared to be totally random (probably because Microsoft is redirecting the connection requests to different servers and their security policies differ, not sure.). Sometimes the emails have been sent and sometimes they have not. Finally, after applying the solution in the link you have provided we did not experience any issue. Many thanks.
    – rasso
    Jan 28 at 7:04
2

I can definitely answer at least the second part of your question. It is possible to configure retry attempts and the retry delay that Database Mail uses. You can do this with the sysmail_configure_sp procedure (see the AccountRetryAttempts and AccountRetryDelay parameters), or you can configure the same settings through SSMS by right clicking on Database Mail in the Object Explorer and going to the "View or change system parameters" screen.

On the first part of your question about identifying the root cause of the failure, you could try checking system and application logs in Event Viewer or the SQL Server logs to see if this gives any extra detail about the errors. Also, I have seen an error like this recently caused by a change TLS support in Office 365. If you are using Office 365 as your mail server you should check that SQL Server is on a version that supports TLS 1.2 and force TLS 1.2 as per this stack overflow question. TLS 1.0 and 1.1 are no longer officially supported by Office 365 and lately they only work inconsistently.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.