Share via

DatabaseMail Stuck with SQL Server 2019 + Windows Server 2019

ErezK 1 Reputation point
2020-10-27T10:20:48.667+00:00

Hello,

I am using Database Mail with SQL Server 2019 CU8 standard edition, on the Server 2019 standard (update).
My SMTP server is gmail.smtp.com 587 with secure
Google Apps Email account - Turn Allow less secure apps ON
No FireWall

Some days after we moved to our new server (SQL server 2019), I notice that my customers stop getting emails.

using query

SELECT sent_status, *
FROM dbo.sysmail_allitems WITH(NOLOCK READUNCOMMITTED)
ORDER BY send_request_date desc

returns a lot of fails\unsent emails

When I checked the log viewer
I found strange errors

Cannot send mails to the mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at)

OR

Sending Mail using Account 1 (2020-10-27T11:48:18). Exception Message: Cannot send mails to mail server. (The operation has timed out.).

My workaround

1.delete queue

DECLARE @GETDATE datetime
SET @GETDATE = GETDATE();
EXECUTE msdb.dbo.sysmail_delete_mailitems_sp @sent_before = @GETDATE;
GO

2.Kill Databasemail.exe process from the task manager

3.EXEC dbo.sysmail_stop_sp
4.EXEC dbo.sysmail_start_sp

And why it so strange?

Because from that point, everything works like a charm...
the service sends hundreds of emails with the same email account, same profile setting.
It looks like the Database Mail log errors not related to the case...

What's going on?

PS
With the same setting on our old SQL SERVER 2012 EXPRESS, everything works fine for years ...

SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

0 comments No comments

6 answers

Sort by: Most helpful
  1. ErezK 1 Reputation point
    2020-11-01T13:14:22.837+00:00

    It`s true.
    the problem was the network
    a fault network card without any error

    I change the card and everything works smooth

    Was this answer helpful?

    0 comments No comments

  2. m 4,286 Reputation points
    2020-10-29T01:58:51.82+00:00

    Hi @ErezK ,

    Please close your firewall and antivirus softwares to have a test.

    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2020-10-28T09:43:16). Exception Message: Cannot send >mails to mail >server. (The operation has timed out.).

    From this message, we can know the mail server failure. You need to check whether the mail server is running well.

    Exception Message: Cannot send mails to mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 >Must issue a >STARTTLS command first. w25sm2418286ejy.123 - gsmtp).

    From this message, we can see that the SMTP server can not recognize your request. Or the SMTP thinks your request is not one secure one connection. So it refuse the client's request.Whether there are some security settings in your SMTP server side?

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Was this answer helpful?


  3. m 4,286 Reputation points
    2020-10-28T08:52:09.527+00:00

    Hi @ErezK ,

    So do you try to create one new profile and new account to have a test?
    35694-20201028nreprofilenewaccount.jpg

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Was this answer helpful?


  4. m 4,286 Reputation points
    2020-10-28T07:23:08.573+00:00

    Hi @ErezK ,

    Cannot send mails to the mail server. (The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.0 Authentication Required. Learn more at) OR Sending Mail using Account 1 (2020-10-27T11:48:18). Exception Message: Cannot send mails to mail server. (The operation has timed out.).

    Quote from this case: the-smtp-server-requires-a-secure-connection-or-the-client-was-not-authenticated
    First check for gmail's security related issues. You may have enabled double authentication in gmail. Also check your gmail inbox if you are getting any security alerts.

    You can also reconfigure your database mail to have a test.

    More information: setup-sql-server-database-mail-to-use-a-gmail-hotmail-or-outlook-account

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Was this answer helpful?


  5. Tom Phillips 17,786 Reputation points
    2020-10-27T12:15:31.643+00:00

    You are likely running into the gmail SMTP limits. Please see:

    https://support.google.com/a/answer/166852

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.