使用SMTP发送邮件时,SQL Server中的邮件发送失败 [英] Mail send is failed in SQL server when sending mail using SMTP
本文介绍了使用SMTP发送邮件时,SQL Server中的邮件发送失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想使用sql server发送邮件并在sql server中接收邮件
但是它给出了以下错误
I want to send mail using sql server and also receive mail in sql server
but It gives following error
The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 16 (2017-09-08T11:32:55). Exception Message: Cannot send mails to mail server. (Service not available, closing transmission channel. The server response was: Cannot connect to SMTP server 8.8.4.4 (8.8.4.4:25), connect error 10060).
)
我尝试过:
What I have tried:
1)
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'Asus01',
@description = 'Sent Mail using MSDB',
@email_address = '[EDIT: Removed user name]@gmail.com',
@display_name = 'Vinayak',
@username='[EDIT: Removed user name]@gmail.com',
@password='[EDIT: Removed password]',
@mailserver_name = 'google-public-dns-b.google.com'
when Fire query
select * from sysmail_account
输出是
output is
17 Asus01 Sent Mail using MSDB vinayak.paul2011@gmail.com Vinayak NULL 2017-09-08 12:31:30.853 sa
2)
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'Asus01',
@description = 'Profile used to send mail'
-- select * from sysmail_profile
此查询提供以下输出
this query gives following output
13 Asus01 Profile used to send mail 2017-09-08 12:41:50.767 sa
3)
3)
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'Asus01',
@account_name = 'Asus01',
@sequence_number = 1
--select * from sysmail_profileaccount
此查询提供以下输出
this query gives following output
13 17 1 2017-09-08 12:44:37.163 sa
4)
4)
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'Asus01',
@principal_name = 'public',
@is_default = 1 ;
5)
发送邮件
5)
Send Mail
exec msdb.dbo.sp_send_dbmail @profile_name = 'Asus01', @recipients = 'paulvinayak70@gmail.com', @subject = 'Mail Test', @body = 'Mail Sent Successfully', @body_format = 'text'
6)消防查询
6) Fire query
select * from sysmail_allitems
select * from
在sent_status列中显示
fist in sent_status column it show
unsent
然后在一段时间后
then after some time
sent_status column
显示
failed
推荐答案
您已经在使用SQL Server发送邮件时出错 [ ^ ]。
我对这个问题的回答仍然有效:
您必须确保使用有效的SMTP服务器。
但问题似乎是你不知道什么是SMTP服务器:
这是一个接受传入电子邮件的服务器(现在通常需要注册/拥有一个帐户)。您必须使用与电子邮件客户端程序中相同的设置来使用已使用的邮件帐户。
即 smtp.googlemail.com Gmail而非 google-public-dns-b.google.com 这是一个DNS服务器。
但上述Google邮件服务器将不接受端口25的邮件。它仅支持带有SSL的端口465和带有TLS的端口587。另请参阅使用SMTP设置从打印机,扫描仪或应用程序发送邮件 - G Suite管理员帮助 [ ^ ]。
注意:
我将编辑您的问题并隐藏您的帐户信息(尤其是密码)。
You have already asked this at Error while sending mail using SQL server[^].
And my answer from that question is still valid:
You have to ensure that you are using a valid SMTP server.
But the problem seems to be that you don't know what an SMTP server is:
It is a server that accepts incoming email (which requires nowadays usually to be registered / having an account). You have to use the same settings as in your email client program for the used mail account.
That is smtp.googlemail.com for Gmail and not google-public-dns-b.google.com which is a DNS server.
But the above Google mail server will not accept mails at port 25. It supports only port 465 with SSL and port 587 with TLS. See also Use SMTP settings to send mail from a printer, scanner, or app - G Suite Administrator Help[^].
NOTE:
I will edit your question and obscure your account information (especially the password).
这篇关于使用SMTP发送邮件时,SQL Server中的邮件发送失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文