首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >dbmail间歇发送失败

dbmail间歇发送失败
EN

Database Administration用户
提问于 2020-05-12 15:11:38
回答 1查看 1.9K关注 0票数 0

我们有一个SQL作业,每天运行,将emais发送给我们的驱动程序,并提供第二天的日程安排。

对于85%的驱动程序来说,电子邮件无法从SQL服务器中取出。其他15%的发送没有错误。

我检查了日志并看到了以下错误:

由于邮件服务器故障,无法将邮件发送给收件人。(使用帐户3发送邮件(2020-03-22T16:00:06)异常消息:无法向邮件服务器发送邮件。(发送邮件失败)。)

有没有人知道出了什么问题,或者如何得到更详细的错误?

这个问题是在我们将服务器迁移到一个新的数据中心之后开始的。

我们正在Windows 2008 R2主机上运行Server 2014。

EN

回答 1

Database Administration用户

发布于 2020-05-12 18:25:18

SQL邮件发送失败添加到LowlyDBA注释中引用的

从这个问题中:

数据库邮件的综合故障诊断

首先,我将看到以下查询的结果(因为您已经启动并运行了dbmail ):

代码语言:javascript
复制
--==============================================================
-- I’m doing a TOP 100 on these next several queries as they tend
-- to contain a great deal of data.  Obviously if you need to get
-- more than 100 rows this can be changed.
-- Check the database mail event log.
-- Particularly for the event_type of "error".  These are where you
-- will find the actual sending error.
--==============================================================
SELECT TOP 100 * 
FROM msdb.dbo.sysmail_event_log 
ORDER BY last_mod_date DESC;


--==============================================================
-- Check the actual emails queued
-- Look at sent_status to see 'failed' or 'unsent' emails.
--==============================================================
SELECT TOP 100 * 
FROM msdb.dbo.sysmail_allitems 
ORDER BY last_mod_date DESC;


--==============================================================
-- Check the emails that actually got sent. 
-- This is a view on sysmail_allitems WHERE sent_status = 'sent'
--==============================================================
SELECT TOP 100 * 
FROM msdb.dbo.sysmail_sentitems 
ORDER BY last_mod_date DESC;


--==============================================================
-- Check the emails that failed to be sent.
-- This is a view on sysmail_allitems WHERE sent_status = 'failed'
--==============================================================
SELECT TOP 100 * 
FROM msdb.dbo.sysmail_faileditems 
ORDER BY last_mod_date DESC

根据这些查询的结果,有几种方法可以排除故障。

也许问题不在sql中?为此,我使用powershell发送了几封测试邮件,看看是否一切正常。(更改下面脚本中的详细信息)

代码语言:javascript
复制
$smtpServer = "200.1.1.223"
$smtpPort = 25
$emailFrom = "donotreply@xxxxx.co.uk"
$emailTo = "mmiorelli@xxxxx.co.uk"
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$smtp.Port = $smtpPort
$subject = "ccatsql" 
$body = "test email from ccatsql " 
$smtp.Send($emailFrom, $emailTo, $subject, $body)

检查是否安装了.Net框架3.5 --这可能导致奇怪的错误,即使在sql server 2016中也是如此。

服务器2016 -数据库邮件没有.NET 3.5无法工作

根据我自己的经验,有时,如果.NET 3.5或任何底层组件丢失或损坏,则不会将错误写入任何日志。

要解决这个问题(只有如果这是问题的话),您可以实现以下任何一个:

  1. 创建DatabaseMail.exe.config并将其放在Binn文件夹下的DatabaseMail.exe旁边。

您可以使用notepad.exe或任何其他编辑器来编辑它。

只需确保您使用UTF-8编码保存它(在notepad.exe中,选择save .在编码组合框中,选择UTF-8):

  1. 运行Server 2016的修复设置操作。
  2. 在机器上手动安装.Net Framework3.5。

请参阅有关这个答案的更多信息。

票数 1
EN
页面原文内容由Database Administration提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://dba.stackexchange.com/questions/267020

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档