最近写了一个监控日志程序的小功能,其中的一个步骤就是在检查到日志有ERROR级别的错误信息时,截取错误信息并发送到指定的邮箱。
最初配置
mail: host: smtp.exmail.qq.com username: xxxx.com password: xxxxx properties.mail.smtp.auth: true port: 25
这里使用了25端口,在线上环境使用时,发现报错:Couldn't connect to host, port: smtp.exmail.qq.com, 25; timeout -1
刚才并不清楚原因,首先服务器Telnet smtp.exmail.qq.com 25端口,发现25端口不通,肯定会发生连接超时。
查询原因是阿里云管控垃圾邮件,封了25端口服务,可以使用ssl方式的465端口进行邮件的发送。
更改后的配置
mail:
host: smtp.exmail.qq.com
username: xxxx.com
password: xxxxx
properties.mail.smtp.auth: true
port: 465
properties.mail.smtp.starttls.enable: true
properties.mail.smtp.starttls.required: true
properties.mail.smtp.ssl.enable: true
使用了465端口进行邮件的发送,并且配置ssl为true
参考:https://blog.youkuaiyun.com/weixin_41933666/article/details/81001914