nested exception is javax.mail.MessagingException: Exception reading response

场景

使用springboot mail发邮件,利用到公司的邮件服务器。先在本地写好代码在本地单元测试时报错

org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset. Failed messages: javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset
; message exception details (1) are:
Failed message 1:
javax.mail.MessagingException: Exception reading response;
nested exception is:
java.net.SocketException: Connection reset

大意是连接被重置
查询资料一开始说需要配置超时时间在yaml里,配置完成后仍然失败

spring:
 mail:
  host: XX.com
  port: 25
  username: XXP@XX-auto.com
  properties:
   mail:
    debug: true
    smtp:
      #设置邮件发送超时时间
     timeout: 25000

解决

又查询了资料,发现 connect reset 问题有人是这样说。

网络策略阻止了对SMTP服务器的请求。我与网络管理员联系,他给了我所需的权限。现在一切正常。

对啊,我现在用的是公司的邮件服务器发邮件,肯定做了限制公司,我在本地机器上怎么可能发送成功呢,哪怕我连上了公司的vpn?
然后我将程序打个jar包放到公司集群某台机器中,果然发送成功,outlook收到了邮件
在这里插入图片描述后续和同事确认了之前的连接问题就是公司服务器配置问题

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值