背景
最近在全职负责的报表开发平台,有一个看板订阅功能,即按照设置的调度时间定时把看板数据加载为字节流发送到用户配置的指定邮箱。
然后偶发性地出现邮件发送失败问题,执行日志截图:
排查
上面报错日志:
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)
收不到邮件
几种可能:
- 用户已离职,此账户在LDAP系统已处于失效状态
- 邮件地址有误,比如本应发送给@google.com,用户填写收件地址时写错为@gooogle.com
- 收件人的邮箱已满
- 邮件内容体过大
- 邮件server端有发送记录却收不到邮件
有些时候,mail server端有发送成功的记录,但是收件人反馈收不到邮件
得找IT运维排查下邮件发送记录,以下面的截图为准
- 邮箱地址失效
邮件发送失败
报错信息:
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.
咨询网络运维给的答复:
邮箱环境是个云端和本地混合部署的 两边都有服务器,然后主邮箱再云端,本地会有一个类似映射关系的邮箱属性在。主邮箱在哪就会直接投递过去,只是这个用户主邮箱找不到(已离职),只找到映射关系所以投到本地,但是本地只是个属性 没有实际的邮箱存在,所以退信。发送失败。
- 邮件转发规则设置有误
在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.
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/142127.html