sql-server - SQL Server 2014 数据库邮件未发送
问题描述
我在 SQL Server 2014 上并且玩得很开心......我的 DB 邮件没有发送,而且我没有地方可以查看了。我仔细检查了 DBmail 可执行文件的 SQL 帐户权限 - 它已读取并执行。我尝试了另一个具有相同未发送问题的邮件帐户和配置文件。
我正在按照此处所述的查询运行
步骤1
检查 dbowner 的权限
设置#2
USE MASTER
GO
SP_CONFIGURE 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
GO
SP_CONFIGURE 'Database Mail XPs', 1
RECONFIGURE WITH OVERRIDE
GO
SP_CONFIGURE 'show advanced options', 0
RECONFIGURE WITH OVERRIDE
GO
及以上查询成功运行,没有任何错误
步骤#3
使用以下查询配置数据库邮件
EXECUTE msdb.dbo.sysmail_add_profile_sp
@profile_name = 'P2PEmailNotifications',
@description = 'Profile used for sending outgoing notifications using Gmail.' ;
GO
EXECUTE msdb.dbo.sysmail_add_principalprofile_sp
@profile_name = 'P2PEmailNotifications',
@principal_name = 'public',
@is_default = 1 ;
GO
EXECUTE msdb.dbo.sysmail_add_account_sp
@account_name = 'MyGmail',
@description = 'Mail account for sending outgoing notifications.',
@email_address = 'MyGmailSMTPEMAIL@gmail.com',
@display_name = 'no-reply@ubl.com.pk',
@mailserver_name = 'smtp.gmail.com',
@port = 555,
@enable_ssl = 1,
@username = 'MyGmailSMTPEMAIL@gmail.com',
@password = 'xxxxxxx' ;
GO
EXECUTE msdb.dbo.sysmail_add_profileaccount_sp
@profile_name = 'P2PEmailNotifications',
@account_name = 'MyGmail',
@sequence_number =1 ;
GO
第4步
现在,尝试使用以下查询执行 dbmail:
EXEC [msdb].[dbo].[sp_send_dbmail]
@profile_name = 'P2PEmailNotifications',
@recipients = 'xxx.xxx.xxx@outlook.com',
@subject = @Subject2,
@body = @Body2,
@body_format = 'HTML'
输出
现在,我可以在结果窗口中找到任何错误。
步骤#5
所以,我得到了这些查询来检查发送 dbmail 时是否有任何错误并运行它:
SELECT *
FROM msdb..sysmail_event_log
ORDER BY log_id DESC
这是描述列中的错误:
由于邮件服务器故障,无法将邮件发送给收件人。(使用帐户 9 发送邮件(2019-04-11T00:21:06)。异常消息:无法连接到邮件服务器。(连接尝试失败,因为连接方在一段时间后没有正确响应,或建立连接失败,因为连接的主机未能响应 64.233.167.109:555)。)
SELECT * FROM dbo.sysmail_sentitems
看到错误后,我通过更改不同的 gmail 电子邮件并将端口 555 更改为 587 重复了第 3 步,之后我在描述列中收到了以下错误
异常信息
异常类型:Microsoft.SqlServer.Management.SqlIMail.Server.Common.BaseException
消息:无法从队列中检索项目。原因:可以发送此邮件的帐户列表为空(可能是由于使用了无效的配置文件)。
数据:System.Collections.ListDictionaryInternal
TargetSite:Microsoft.SqlServer.Management.SqlIMail.Server.Controller.ICommand CreateSendMailCommand(Microsoft.SqlServer.Management.SqlIMail.Server.DataAccess.DBSession)
HelpLink:NULL
来源:DatabaseMailEngine
StackTrace 信息
在 Microsoft.SqlServer.Management.SqlIMail.Server.Controller.CommandRunner.Run
(DBSession db) 在 Microsoft.SqlServer.Management.SqlIMail.IMailProcess的 Microsoft.SqlServer.Management.SqlIMail.Server.Controller.CommandFactory.CreateSendMailCommand(DBSession dbSession) .ThreadCallBack.MailOperation(对象 obj)
结论
我有一个发送状态为“失败”的项目队列。正如我简要描述我的问题一样。因此,我需要开发人员提供一些答案,即我在上述步骤中做错了什么是我遗漏了一些东西,或者这是我在搜索中没有的 SQL Server 2014 的一个已知问题?发送此邮件的任何其他可能步骤?
解决方案
推荐阅读
- tensorflow - 如何实时更新张量板图而不在model.fit函数中回调?
- node.js - 用户验证失败:密码:需要路径“密码”
- r - 在 v.4.1.0 中找不到 R 函数 seas()
- javascript - Polly Bulkhead 在 ASP.NET Core 中使用时出现意外行为
- flutter - 列子项的动态高度
- javascript - 在ckeditor中粘贴内容并发送邮件时出现问题
- google-bigquery - 在 BigQuery 中,带有空值数组列的“where”子句导致问题
- ios - 当 ios 应用程序在后台并且有人选择它时调用警报声音,使用核心运动
- ios - 从 Xcode 生成 Package.swift
- azure-application-insights - Azure App Insights 操作计数异常高