我使用Simple Java Mail框架发送邮件。 我在那里阅读了文档 - simplejavamail.org。
我的代码:
Email email = new Email();
email.setFromAddress("SomeOne1", "someone1@aol.com");
email.setSubject("Newsletter");
email.addRecipient("SomeOne2", "someone2@aol.com", Message.RecipientType.TO);
email.setText("Some text");
email.setTextHTML("there my html");
new Mailer("smtp.aol.com", 587, "testjavasimplemail@gmail.com", "hunter2", TransportStrategy.SMTP_TLS).sendMail(email);
但现在我有错误:
июн 25, 2015 6:30:47 PM org.codemonkey.simplejavamail.Mailer sendMail
SEVERE: null
javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:242)
at pkg.Main.main(Main.java:39)
Exception in thread "main" org.codemonkey.simplejavamail.MailException: Generic error: null
at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:250)
at pkg.Main.main(Main.java:39)
Caused by: javax.mail.AuthenticationFailedException
at javax.mail.Service.connect(Service.java:319)
at javax.mail.Service.connect(Service.java:169)
at javax.mail.Service.connect(Service.java:118)
at org.codemonkey.simplejavamail.Mailer.sendMail(Mailer.java:242)
... 1 more
出了什么问题?
答案 0 :(得分:1)
您使用的是错误的SMTP服务器。你需要一个GMail。
"smtp.aol.com" -> "smtp.gmail.com"
答案 1 :(得分:0)
您正在使用Gmail帐户连接到aol smtp服务器!
尝试使用好的参数......