1、端口是465,并且使用ssl加密协议
email.setHostName("smtp.qq.com") email.setSSL(true) email.setSmtpPort(465)
2、邮箱需要开启POP3/SMTP服务
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)