无法从SQL Server发送电子邮件 [英] Unable to send email from SQL Server
问题描述
我正在尝试从SQL Server发送电子邮件到触发器.我已经按照此中的指导进行了操作博客.每当我尝试发送电子邮件时,都会收到错误消息.
I am trying to send an email from SQL Server to Trigger. I have performed as per the guidance in this blog. Whenever I am trying as email, I am getting an error.
EXEC msdb.dbo.sysmail_add_account_sp
@account_name = 'ChandreshTestAccount'
, @description = 'Sending email from test account'
, @email_address = 'chandresh.cmk@gmail.com'
, @display_name = 'No-Reply'
, @replyto_address = 'chandresh.cmk@gmail.com'
, @mailserver_name = 'smtp.gmail.com'
, @port = 25
, @username = 'chandresh.cmk@gmail.com'
, @password = 'xxxxxxx'
Go
错误:由于以下原因,邮件无法发送给收件人邮件服务器故障.(使用帐户6发送邮件(2017-02-02T14:24:46).异常消息:无法连接到邮件服务器.(连接尝试失败,因为被连接方做了一段时间后没有正确响应,或者建立了连接失败,因为已连接的主机未能响应74.125.68.109:25).)
Error: The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 6 (2017-02-02T14:24:46). Exception Message: Could not connect to mail server. (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.68.109:25). )
然后我尝试更改端口号587,并收到以下错误.
Then I have tried to change the port number 587 and got the below error.
由于邮件原因,邮件无法发送给收件人服务器故障.(使用帐户5发送邮件(2017-02-02T14:28:22).异常消息:无法将邮件发送到邮件服务器.(SMTP服务器需要安全连接或客户端未通过身份验证.这服务器响应为:5.7.0必须首先发出STARTTLS命令.n8sm30283000pgc.16-gsmtp).)
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 5 (2017-02-02T14:28:22). 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. n8sm30283000pgc.16 - gsmtp). )
然后我再次尝试更改端口号465,并收到以下错误消息
Then again I have tried to change the port number 465 and got the below error
由于邮件原因,邮件无法发送给收件人服务器故障.(使用帐户4(2017-02-02T14:28:19发送邮件).异常消息:无法将邮件发送到邮件服务器.(失败发送邮件.).)
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 4 (2017-02-02T14:28:19). Exception Message: Cannot send mails to mail server. (Failure sending mail.). )
有什么我想念的吗?注意:我正在本地计算机"中尝试此操作,并且能够通过 Port 25
Is there anything I am missing?
Note: I am trying this in Local Machine and I am able to send email from C#
code with Port 25
谢谢.
推荐答案
如问题与解答 MSDN:如何将SQL Server数据库邮件配置为使用Windows Live Mail帐户或GMail帐户发送电子邮件,依此类推,您需要使用端口587 和安全连接,因为收到的错误表明:
As explained in the Q&A Sending email in .NET through Gmail, on MSDN: How to configure SQL Server Database Mail to send email using your Windows Live Mail Account or your GMail Account and so on, you need to use port 587 and a secure connection, as the error you received indicates:
5.7.0必须首先发出STARTTLS命令
5.7.0 Must issue a STARTTLS command first
因此,按照 查看全文