email - How to send mail using Simple Java Mail framework? -
i use simple java mail framework sending mail. read documentation there - simplejavamail.org.
my code:
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 html"); new mailer("smtp.aol.com", 587, "testjavasimplemail@gmail.com", "hunter2", transportstrategy.smtp_tls).sendmail(email);
but have error:
июн 25, 2015 6:30:47 pm org.codemonkey.simplejavamail.mailer sendmail severe: null javax.mail.authenticationfailedexception @ javax.mail.service.connect(service.java:319) @ javax.mail.service.connect(service.java:169) @ javax.mail.service.connect(service.java:118) @ org.codemonkey.simplejavamail.mailer.sendmail(mailer.java:242) @ pkg.main.main(main.java:39) exception in thread "main" org.codemonkey.simplejavamail.mailexception: generic error: null @ org.codemonkey.simplejavamail.mailer.sendmail(mailer.java:250) @ pkg.main.main(main.java:39) caused by: javax.mail.authenticationfailedexception @ javax.mail.service.connect(service.java:319) @ javax.mail.service.connect(service.java:169) @ javax.mail.service.connect(service.java:118) @ org.codemonkey.simplejavamail.mailer.sendmail(mailer.java:242) ... 1 more
what's wrong?
you're using wrong smtp server. need gmail one.
"smtp.aol.com" -> "smtp.gmail.com"
Comments
Post a Comment