SQL Server sp_send_dbmail - 如何向Gmail发送邮件?

Mar*_*arc 5 sql-server sp-send-dbmail

sp_send_dbmail除了我使用Gmail帐户发送给收件人时,我正在使用哪个工作正常.数据库邮件日志提供以下错误:

Error,80,The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 2 (2015-05-29T13:22:39). Exception Message: Cannot send mails to mail server. (Unable to send to a recipient.))
Run Code Online (Sandbox Code Playgroud)

所有未使用Gmail的收件人都会正确收到邮件.

当我手动使用Outlook向此Gmail帐户发送邮件时,它正在运行.收件人正确收到邮件.SQL Server邮件帐户未使用Gmail.我使用端口25和SSL(我试过没有SSL,它也没有工作).

程序调用如下:

EXEC msdb.dbo.sp_send_dbmail 
    @recipients = 'somemail@company.com;somemail@gmail.com',
    @copy_recipients = 'somemail@company.com',
    @profile_name = 'my_profile',
    @subject = 'mail subject',
    @body = 'some content',
    @body_format = 'Text';
Run Code Online (Sandbox Code Playgroud)

小智 1

我在 SSMS 中测试了 sp_send_dbmail 过程,它对于 gmail 运行良好。在消息面板上,我收到消息“邮件已排队”。您可以使用以下方法排除队列故障: msdb..sysmail_help_queue_sp @queue_type = 'Mail' ;

对我来说,这看起来像是 smtp 邮件中继问题。您还应该测试数据库邮件配置文件设置。