SQL SERVER – Database Mail Error: The SMTP Server Requires a Secure Connection or the Client was not Authenticated. The Server Response Was: 5.5.1

Have you ever configured database mail using Gmail account? There are many articles on the internet describing the steps. In this blog, we would learn about fixing an error “The SMTP server requires a secure connection or the client was not authenticated” which you might see when database mail is used. Note that this can also appear for non-Gmail setups also. So, here we go.

THE PROBLEM

I was working on a project with my client and they had a requirement to send alerts via database mail. They wanted to use Google’s email service i.e. Gmail for this. As soon as they configured and sent a test email, we received below error while sending a test email.

Log Database Mail (Database Mail Log)
Process ID: 2654
Mail Item ID: 23
Last Modified By: sa
Message: The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (DateTime). 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.5.1 Authentication Required. Learn more at).)

And of course, mail went to unsent/failed state.

SOLUTION/WORKAROUND

It took a while to find a solution as there were many solutions available on the internet. In our case, it was a checkbox. If you run into the same error, make sure that you check below checkbox under account setting section of database mail.

SQL SERVER - Database Mail Error: The SMTP Server Requires a Secure Connection or the Client was not Authenticated. The Server Response Was: 5.5.1 dbmail-ssl-01-800x359

After this, we sent another test email and it was successfully delivered to the recipient.

While searching on the internet, I was also able to find another error which is fixed by the same setting. Here is the error:

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).’

Above error is also due to SSL checkbox.

Reference: Pinal Dave (https://blog.sqlauthority.com)

, , ,
Previous Post
SQL SERVER – Many BACKGROUND Threads with Command VDI_CLIENT_WORKER
Next Post
SQL SERVER – gMSA: The Service Did Not Start Due to a Logon Failure

Related Posts

7 Comments. Leave new

  • Hi, I’m still getting that error though I checked that box.

    Reply
  • I got the same error.
    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2018-08-23T23:57:04). 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.5.1 Authentication Required. Learn more at).
    )

    even if the settings and credential in my outlook is the same.

    Reply
  • Martin Theunissen
    June 7, 2019 7:43 pm

    I had a similar issue, after checking everything I deleted and re-created the mail account and profile and it worked.

    Reply
  • Rajugowda CM
    July 9, 2019 4:38 pm

    Hi Pinal,

    I got below error while configuring db mail in SQL 2017.

    Message
    The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2019-07-04T11:13:02). Exception Message: Cannot send mails to mail server. (Mailbox unavailable. The server response was: 5.7.1 Unable to relay for EMAILID).

    Reply
  • mirzahabeeb786abeeb
    July 6, 2020 4:09 pm

    I am getting below error and I did many things still when send a mail DBMail stopped itself

    Date 6/29/2020 10:46:11 PM
    Log Database Mail (Database Mail Log)

    Log ID 7575
    Process ID 13880
    Last Modified 6/29/2020 10:46:11 PM
    Last Modified By NT AUTHORITYNETWORK SERVICE

    Message
    1) Exception Information
    ===================
    Exception Type: Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException
    Message: The Transaction not longer valid.
    Data: System.Collections.ListDictionaryInternal
    TargetSite: Void ValidateConnectionAndTransaction()
    HelpLink: NULL
    Source: DatabaseMailEngine
    HResult: -2146232832

    StackTrace Information
    ===================
    at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.ConnectionManager.ValidateConnectionAndTransaction()
    at Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.ConnectionManager.RollbackTransaction()
    at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.QueueItemProcesser.GetDataFromQueue(DataAccessAdapter da, Int32 lifetimeMinimumSec)
    at Microsoft.SqlServer.Management.SqlIMail.IMailProcess.QueueItemProcesser.ProcessQueueItems(String dbName, String dbServerName, Int32 lifetimeMinimumSec, LogLevel loggingLevel, Byte[] encryptionKey, Int32 connectionTimeout)

    Can you help me please…

    Reply

Leave a Reply

Menu