发送邮件报错:
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:310)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at javax.mail.Transport.send0(Transport.java:188)
at javax.mail.Transport.send(Transport.java:118)
at qnit.common.email.EmailTool.sendHtmlMail(EmailTool.java:111)
解决办法:
1. 查看邮箱与邮件服务器是否一致[如果用126的邮件发送服务器,则设置的发送邮箱必须是126的邮箱],验证邮箱用户名密码
2. 查看邮箱是否开启smtp服务,设置->pop3/smtp/imap ->选中pop3/smtp 服务 ->设置授权->保存
如果报以下错误:
javax.mail.AuthenticationFailedException: 550 Óû§ÎÞȨµÇ½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)
用户名密码输错,
此处填写 邮箱账号及客户端授权码[邮箱登陆密码是不对的]
如果还报错,重启下你的工程,因为校验邮箱时,有缓存,即使使用了正确的密码也会校验失败