4

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?
askolotl
  • 255
  • 1
  • 3
  • 10

2 Answers2

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.

jbz
  • 327
  • 4
  • 8
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.

Brenton
  • 219
  • 1
  • 3