Sending mail in SQL Server using a Gmail account

JDias 136 Reputation points
2021-03-25T16:50:47.813+00:00

I have tried to send test emails from SQL Server 2012 and SQL Express through a gmail account without the desired result.

I tried both SSL (port 465) and TLS (port 587), but errors occured in both:

TLS:
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2021-03-25T15:52:59). Exception Message: Cannot send mails to mail server. (O servidor SMTP requer uma ligação segura ou o cliente não estava autenticado. A resposta do servidor foi: 5.7.0 Must issue a STARTTLS command first. 1sm6939762wmj.2 - gsmtp). )

SSL:
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2021-03-25T15:47:01). Exception Message: Cannot send mails to mail server. (Falha ao enviar correio.). )

However, I have managed to send emails throgh the Gmail account using python and .NET Core MailKit.

What could have happened?

For SSL I used the following settings:

EXECUTE msdb.dbo.sysmail_add_account_sp
@Creat _name = 'MailTest',
@description = 'Send Mail using MSDB',
@tiedtlaw email _address = 'me@Stuff .com',
@publicly _name = '@gmaeil.com',
@port = 465,
@enable_ssl = 1,
@Tablet ='me@Stuff .com',
@Lee ='
***********',
@mailserver_name = 'smtp.gmail.com'
GO

SQL Server | Other
0 comments No comments
{count} vote

Accepted answer
  1. CarrinWu-MSFT 6,891 Reputation points
    2021-03-26T05:31:00.467+00:00

    Hi @JDias ,

    Some suggetions in troubleshooting this issue:

    1. Not ticking "This server requires a secure connection (SSL)" in the outgoing SMTP server settings of the Mail account.
    2. Permissions: The user creating the profiles accounts and executing stored procedures should be a member of the sysadmin fixed server role.
    3. please check database mail is enabled
    4. please check users are properly configured to send mail
    5. please check database mail is started
    6. Do problems affect some or all accounts
    7. Retry mail delivery

    Please refer to General database mail troubleshooting steps to get more details.

    Best regards,
    Carrin


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    2 people found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Tarek Halloun 36 Reputation points
    2022-05-04T11:56:42.497+00:00

    i am having the same issue on sql 2019 , even 587 and ssl is not working

    1 person found this answer helpful.
    0 comments No comments

Your answer

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