使用QQ邮箱,发送邮件配置问题!

1、端口是465,并且使用ssl加密协议

email.setHostName("smtp.qq.com")
email.setSSL(true)
email.setSmtpPort(465)

2、邮箱需要开启POP3/SMTP服务

image.png

3、最后填账号密码时候,这个密码必须是QQ邮箱给你的授权码,不然就认证失败!授权码获取https://service.mail.qq.com/cgi-bin/help?subtype=1&id=28&no=1001256

错误:

org.apache.commons.mail.EmailException: Sending the email to the following server failed : smtp.qq.com:465

at org.apache.commons.mail.Email.sendMimeMessage(Email.java:1242)

at org.apache.commons.mail.Email.send(Email.java:1267)

at jp.fukuwaraku.erp.common.util.email.EmailKit.sendEmail4ATM(EmailKit.java:126)

at jp.fukuwaraku.erp.common.util.email.EmailKit.main(EmailKit.java:196)

Caused by: javax.mail.AuthenticationFailedException: 535 Error: ÇëʹÓÃÊÚȨÂëµÇ¼¡£ÏêÇéÇë¿´: http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256


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 org.apache.commons.mail.Email.sendMimeMessage(Email.java:1232)


评论区

hb963724769

2019-07-13 11:23

使用过程中,好像还填了一个mail.jar包在项目中,才跑起来,光一个commons-email-1.5.jar还不够!会报一个找不到类的错误。

JFinal

2019-07-13 11:51

邮件服务提供商这几年对于客户端的支持有变化,有不少同学碰到过无法使用的问题,感谢你的分享

1659811173

2019-07-16 15:30

mail.jar这个必须要的,兄弟

热门分享

扫码入社