Sending the email to the following server failed.IOException while sending message问题解决

博客内容涉及了一起关于邮件发送失败的问题,错误日志显示SMTP连接异常。故障原因包括用户离职导致邮箱失效、邮件地址错误、邮箱空间不足、邮件内容过大、邮件服务器配置问题以及邮件转发规则设置不当等。经过IT运维的排查,确认问题在于离职员工邮箱已失效,本地邮箱映射导致的投递错误。邮件客户端设置的自动转发规则也可能是原因之一。解决方案包括更新无效邮箱信息、检查邮件地址、调整邮件大小限制和修正转发规则。
摘要由CSDN通过智能技术生成

背景

最近在全职负责的报表开发平台,有一个看板订阅功能,即按照设置的调度时间定时把看板数据加载为字节流发送到用户配置的指定邮箱。
然后偶发性地出现邮件发送失败问题,执行日志截图:
在这里插入图片描述

排查

上面报错日志:

ERROR MailService - sendEmail error
org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.partner.outlook.cn:587
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1421)
	at org.apache.commons.mail.Email.send(Email.java:1448)
	at org.aaa.services.MailService.sendEmail(MailService.java:667)
	at org.aaa.services.MailService.sendEmail(MailService.java:316)
	at org.aaa.services.MailService.sendDashboard(MailService.java:138)
	at org.aaa.services.job.JobService.sendMail(JobService.java:369)
	at org.aaa.services.job.MailJobExecutor.execute(MailJobExecutor.java:129)
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573)
Caused by: javax.mail.MessagingException: IOException while sending message
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1244)
	at javax.mail.Transport.send0(Transport.java:254)
	at javax.mail.Transport.send(Transport.java:124)
	at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1411)
	... 8 common frames omitted
Caused by: java.net.SocketException: Connection reset
	at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:113)
	at java.net.SocketOutputStream.write(SocketOutputStream.java:153)
	at sun.security.ssl.OutputRecord.writeBuffer(OutputRecord.java:431)
	at sun.security.ssl.OutputRecord.write(OutputRecord.java:417)
	at sun.security.ssl.SSLSocketImpl.writeRecordInternal(SSLSocketImpl.java:876)
	at sun.security.ssl.SSLSocketImpl.writeRecord(SSLSocketImpl.java:847)
	at sun.security.ssl.AppOutputStream.write(AppOutputStream.java:123)
	at com.sun.mail.util.TraceOutputStream.write(TraceOutputStream.java:128)
	at java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:82)
	at java.io.BufferedOutputStream.write(BufferedOutputStream.java:126)
	at com.sun.mail.util.CRLFOutputStream.write(CRLFOutputStream.java:84)
	at com.sun.mail.smtp.SMTPOutputStream.write(SMTPOutputStream.java:87)
	at com.sun.mail.util.CRLFOutputStream.write(CRLFOutputStream.java:75)
	at com.sun.mail.util.BASE64EncoderStream.write(BASE64EncoderStream.java:140)
	at javax.activation.DataHandler.writeTo(DataHandler.java:309)
	at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1608)
	at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:961)
	at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:553)
	at com.sun.mail.handlers.multipart_mixed.writeTo(multipart_mixed.java:103)
	at javax.activation.ObjectDataContentHandler.writeTo(DataHandler.java:889)
	at javax.activation.DataHandler.writeTo(DataHandler.java:317)
	at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:1608)
	at javax.mail.internet.MimeMessage.writeTo(MimeMessage.java:1849)
	at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:1196)

收不到邮件

几种可能:

  1. 用户已离职,此账户在LDAP系统已处于失效状态
    在这里插入图片描述
  2. 邮件地址有误,比如本应发送给@google.com,用户填写收件地址时写错为@gooogle.com
  3. 收件人的邮箱已满
    在这里插入图片描述
  4. 邮件内容体过大
    在这里插入图片描述
  5. 邮件server端有发送记录却收不到邮件
    有些时候,mail server端有发送成功的记录,但是收件人反馈收不到邮件
    在这里插入图片描述
    得找IT运维排查下邮件发送记录,以下面的截图为准
    在这里插入图片描述
  6. 邮箱地址失效
    邮件发送失败
    在这里插入图片描述
    报错信息:
Delivery has failed to these recipients or groups:
liyu@johnny.com
Something went wrong and your message couldn't be delivered. This could be a temporary issue. Try resending the message in a few minutes. If that doesn't work, forward this message to your email admin.
For Email Admins
The message couldn't be delivered because a mail routing loop was encountered. This may be due to a routing misconfiguration in the mail flow settings for either your organization or the recipient organization. If mail flow settings were recently updated, this error may be temporary.
Check the message headers in the section below to determine where the loop may be occurring and if it's something you or the email admin for the recipient organization can fix.
For more information, see Error code 5.4.12 in Exchange Online and Office 365.

咨询网络运维给的答复:
邮箱环境是个云端和本地混合部署的 两边都有服务器,然后主邮箱再云端,本地会有一个类似映射关系的邮箱属性在。主邮箱在哪就会直接投递过去,只是这个用户主邮箱找不到(已离职),只找到映射关系所以投到本地,但是本地只是个属性 没有实际的邮箱存在,所以退信。发送失败。

  1. 邮件转发规则设置有误
    在这里插入图片描述
    在outlook里面发送邮件,写草稿箱,是可以正常显示收件人信息:
    在这里插入图片描述
    咨询运维,看日志是发送成功的:
    在这里插入图片描述
    进一步看发送日志:
    在这里插入图片描述
    用户在outlook邮箱客户端,设置过转发规则,转出到外部邮箱,所以邮件发送动作被邮件服务器拒绝。

值得一提的是,客户端设置自动转发规则,有3种:
在这里插入图片描述
前两种是自己收到邮件之后,自己作为邮件发送方,再转发;第三种是直接转发出去。英文版本:
在这里插入图片描述
参考Redirect vs. Forward Email

In a standard forward, the person forwarding the message appears to be the sender. In a redirection, the message appears to come from the original sender.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
当出现 "An I/O error occurred while sending to the backend" 的异常时,这通常意味着客户端与 PostgreSQL 服务器之间的连接已经断开或无法建立,或者在通信过程中出现了网络故障。解决此异常的方法如下: 1. 检查网络连接:首先需要确认网络连接是否正常。可以尝试 ping PostgreSQL 服务器,看看是否能够正常连接。如果网络连接出现问题,需要解决网络问题。 2. 检查 PostgreSQL 服务器状态:检查 PostgreSQL 服务器是否正常运行,并且能够接受新的连接请求。可以尝试使用 psql 工具或其他客户端工具连接 PostgreSQL 服务器,看看是否能够成功连接。 3. 检查 PostgreSQL 服务器日志:如果 PostgreSQL 服务器无法处理客户端请求,可能会在日志中记录错误信息。可以检查 PostgreSQL 服务器的日志文件,找到相关的错误信息,从而确定出错的原因。 4. 调整客户端连接参数:如果客户端连接参数设置不当,可能会导致连接断开。可以尝试调整客户端连接参数,比如增加连接超时时间、调整缓冲区大小等。 5. 升级 PostgreSQL 版本:如果出现此异常的原因是 PostgreSQL 的 bug,可以尝试升级到最新版本,以获得更好的稳定性和更好的性能。 总之,解决 "An I/O error occurred while sending to the backend" 的异常需要结合具体情况进行分析和解决,可以根据异常信息以及上述方法进行排查。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

johnny233

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值