使用spring-boot-starter-mail进行邮件发送的时候,针对普通的邮件、带普通格式的邮件、有附件的邮件发送的时候是没有问题,但是在发送一些有静态资源的邮件时(带图片)会出现Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 554 DT:SPM 163的错误
; message exceptions (1) are:
Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 554 DT:SPM yeah smtp2,C1UQrAC3ROBHsbpecxHIBw--.16331S2 1589293384,please see http://mail.163.com/help/help_spam_16.htm?ip=112.255.14.92&hostid=smtp2&time=1589293384
] with root cause
org.springframework.mail.MailSendException: Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 554 DT:SPM yeah smtp2,C1UQrAC3ROBHsbpecxHIBw--.16331S2 1589293384,please see http://mail.163.com/help/help_spam_16.htm?ip=112.255.14.92&hostid=smtp2&time=1589293384
查看提示的中的地址http://help.163.com/09/1224/17/5RAJ4LMH00753VB8.html发现
中说发送的内容中有问题,可能被识别为垃圾邮件或者病毒邮件,按照网上的一些建议,设置了抄送人依旧报错,于是就思考是不是不同的邮箱的问题。
将配置换成qq的邮箱,进行发送,在第一次测试的时候忘记修改发送人了,qq邮箱报501的错误
nested exception is:
java.net.SocketException: Connection closed by remote host. Failed messages: com.sun.mail.smtp.SMTPSendFailedException: 501 Mail from address must be same as authorization user.
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Mail from address must be same as authorization user.
; message exceptions (1) are:
Failed message 1: com.sun.mail.smtp.SMTPSendFailedException: 501 Mail from address must be same as authorization user.
;
nested exception is:
com.sun.mail.smtp.SMTPSenderFailedException: 501 Mail from address must be same as authorization user.
] with root cause
将发送人修改为qq邮箱,接收人改为网易邮箱,发现图片发送是成功的。(下面的图中使用的邮箱客户端所以备注是自己的邮箱,不是发送给了自己)
于是继续观察,思考是不是发送的目标邮箱有限制,将发送的目标从qq邮件变成网易邮箱本身,于是让人崩溃的事情出现了,发送成功了;
接下来测试一下网易发送给其他的网易邮箱看看效果,结果发送也成功了;
本着有点侥幸的心理,把qq邮箱方到CC上,发现发送的时候还是失败;
把qq邮箱后缀改成@foxmail.com,发送依旧失败;
于是按照手头上有的邮箱简单尝试了下:
gmail : 发送失败
zoho: 发送失败
***soft.com :发送失败
手头上就只有这几个邮箱了,没有继续尝试,初步来看发送自身是正常的。至于其他类型的邮箱也就不进行测试了。