详细报错信息:
Exception in thread “main” cn.hutool.extra.mail.MailException: AuthenticationFailedException: 535 Error: authentication failed
at cn.hutool.extra.mail.Mail.send(Mail.java:358)
at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:395)
at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:140)
at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:123)
at cn.hutool.extra.mail.MailUtil.send(MailUtil.java:64)
at com.provy.jiagou.mail.MailHandler.main(MailHandler.java:12)
Caused by: javax.mail.AuthenticationFailedException: 535 Error: authentication failed
at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at cn.hutool.extra.mail.Mail.doSend(Mail.java:372)
at cn.hutool.extra.mail.Mail.send(Mail.java:356)
… 5 more
问题原因:
在使用hutool时,配置文件中user字段是可以忽略的(针对部分邮箱),但在使用163邮箱时,user为必填,且要和@163.com前缀保持一致。
解决办法:
完整配置如下:
from = aaa@163.com
user = aaa
pass = CNDRRVBLLYSMOKVW
sslEnable = true