在使用JavaMail给QQ邮箱发邮件的过程中虽然碰到了很多问题,但是总结起来大致可以分成一下几类:
第一类:smtp 服 务 未开 启(没有 授 权 码):
因为在用代码发邮件之前,我用的Foxmail添加了QQ邮箱账户,添加的时候报错:-ERR Please using authorized code to login. More information at http://service.mail.qq.com/cgi-bin/help?subtype=1&&id=28&&no=1001256
解决办法自然是开 启 服 务且获取 授 权 码。
第二类:邮箱账户错误、授权码错误、smpt服务器地址错误类。
症状有以下几个:
1、Invalid Addresses:
javax.mail.SendFailedException: Invalid Addresses;
nested exception is:
com.sun.mail.smtp.SMTPAddressFailedException: 550 xxxx@qq.com relay mail disabled.(from "xxxxx@qq.com" to "yyyyyy@qq.com" via "wjl.com")
at com.sun.mail.smtp.SMTPTransport.rcptTo(SMTPTransport.java:1607)
at com.sun.mail.smtp.SMTPTransport.sendMessage(SMTPTransport.java:887)
at javax.mail.Transport.send0(Transport.java:191)
at javax.mail.Transport.send(Transport.java:120)
at com.wjl.mail.utils.MailUtils.sendMain(MailUtils.java:64)
at com.wjl.mail.utils.MailUtils.main(MailUtils.java:71)
Caused by: com.sun.mail.smtp.SMTPAddressFailedException: 550 xxxx@qq.com relay mail disabled.(from "xxxxx@qq.com" to