我正在 SQL Server 2008
中设置数据库邮件,以将邮件发送到我的 Gmail 帐户。以下是我创建的 DBMail
配置文件的详细信息:
email id : xyz@gmail.com
Display Name : xyz
Reply email :
Server name : smtp.gmail.com
port no: 587
Check : This server requires a secure connection
Check : Basic Authentication
username : xyz@gmail.com ( should have gmail.com)
password : <mypassword>
confirm password : <mypassword>
然后我单击“下一步”,并将其设为默认公开个人资料。
然后我使用以下 TSQL
代码来配置和发送 DBMail
:
EXEC sp_CONFIGURE 'show advanced', 1
GO
RECONFIGURE
GO
EXEC sp_CONFIGURE 'Database Mail XPs', 1
GO
RECONFIGURE
GO
use msdb
go
EXEC sp_send_dbmail
@profile_name='XYZ',
@recipients='XYZr@gmail.com',
@subject='Test message',
@body='Message Sent Successfully'
The output appears "Message Queued"
我的消息仍然失败。我觉得我已经正确设置了服务器。任何意见将不胜感激。
SELECT * FROM sysmail_log
正文栏显示
"The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2012-05-16T17:05:00). Exception Message: Could not connect to mail server. (No such host is known). )"
最佳答案
一些建议的故障排除步骤:
尝试使用 SQL Server 所在的同一台计算机,使用 Outlook 等客户端邮件程序,通过同一 SMTP 服务器发送消息。您可能会收到更有意义的错误消息。
端口可能被阻止。尝试使用端口 587 将邮件发送到任何其他 SMTP 服务器。
尝试更改为端口 465。
尝试取消选中您的个人资料中的“需要安全连接”部分。
尝试使用网络内的 SMTP 服务器中继到 GMail。这可能更容易设置和运行。如果没有可用于处理中继的本地 SMTP 服务器,则需要安装 IIS 和 SMTP 组件。
评论 http://mail.google.com/support/bin/answer.py?hl=en&answer=13287
关于sql-server - 通过 SQL Server 发送电子邮件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10626926/