You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SQL Server Reporting Services配置Office 365邮件发送失败求助

问题:SSRS配置Office 365邮件服务失败

已完成Microsoft租户及邮箱配置,在SQL服务器上通过PowerShell的Send-MailMessage脚本测试SMTP发送邮件成功,说明Office 365及主机网络、端口、TLS等配置正常。但配置rsreportserver.config文件后,SQL Server Reporting Services(SSRS)无法发送邮件,报错:Failure sending mail: At least one error has occurred.Mail will not be resent。

测试脚本(PowerShell)

$username = 'office@source.com'
$pass = get-content C:\pwd.txt | ConvertTo-SecureString # 已加密密码
$credentials=new-object Management.Automation.PSCredential -ArgumentList $username, $pass

$param = @{
SmtpServer = 'smtp.office365.com'
Port = 587
UseSsl = $true
Credential = $credentials
Encoding = 'utf8'
From = 'office@source.com'
To = 'target@email.com'
Subject = '[TEST] subject for test'
Body = ' Testing SMTP from o365 '
}

Send-MailMessage @param

rsreportserver.config配置片段

<Configuration>
<RSEmailDPConfiguration>
<SMTPServer>smtp.office365.com</SMTPServer>
<SMTPServerPort>587</SMTPServerPort>
<SMTPAccountName>office@source.com</SMTPAccountName>
<SMTPConnectionTimeout></SMTPConnectionTimeout>
<SMTPServerPickupDirectory></SMTPServerPickupDirectory>
<SMTPUseSSL>True</SMTPUseSSL>
<SendUsing>2</SendUsing>
<SMTPAuthenticate>1</SMTPAuthenticate>
<SendUserName>AQAAANCMnd8BFdERjHo</SendUserName>
<SendPassword>RjHoAwE/Cl+sBAAAA0</SendPassword>
<From>office@source.com</From>
<EmbeddedRenderFormats>
<RenderingExtension>MHTML</RenderingExtension>
</EmbeddedRenderFormats>
<PrivilegedUserRenderFormats></PrivilegedUserRenderFormats>
<ExcludedRenderFormats>
<RenderingExtension>HTMLOWC</RenderingExtension>
<RenderingExtension>NULL</RenderingExtension>
<RenderingExtension>RGDI</RenderingExtension>
</ExcludedRenderFormats>
<SendEmailToUserAlias>False</SendEmailToUserAlias>
<DefaultHostName></DefaultHostName>
<PermittedHosts></PermittedHosts>
</RSEmailDPConfiguration>
</Configuration>

排查与解决步骤

  1. 修正凭证加密格式
    SSRS要求SMTP用户名和密码必须用官方的RSKeyMgmt.exe工具加密,而非PowerShell的加密结果,这是当前配置的核心问题:

    • 打开命令提示符,切换到SSRS工具目录(通常为C:\Program Files\Microsoft SQL Server Reporting Services\SSRS\Tools)
    • 执行命令:RSKeyMgmt.exe -e -f "C:\ssrs_creds.txt",按提示输入SMTP用户名和密码
    • 将生成文件中的UserName和Password值,分别替换到rsreportserver.config的<SendUserName>和<SendPassword>节点
  2. 强制启用TLS 1.2
    Office 365仅支持TLS 1.2及以上版本,需确保SSRS所在服务器已开启:

    • 打开注册表编辑器,定位到HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\v4.0.30319
    • 新建DWORD值SchUseStrongCrypto,设置值为1
    • 重启SSRS服务使配置生效
  3. 验证服务账户权限
    确认SSRS运行的服务账户有权限读取rsreportserver.config文件,且防火墙未限制该账户访问SMTP端口587(即使PowerShell测试通过,服务账户的网络权限可能不同)

  4. 查看详细错误日志
    到SSRS日志目录(通常为C:\Program Files\Microsoft SQL Server Reporting Services\SSRS\LogFiles)查找具体错误信息,比如认证失败、TLS握手异常等,进一步定位问题

内容的提问来源于stack exchange,提问作者scribe

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.09 06:21:29