0

I use Simple Java Mail framework for sending mail. I 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 my html");

        new Mailer("smtp.aol.com", 587, "testjavasimplemail@gmail.com", "hunter2", TransportStrategy.SMTP_TLS).sendMail(email);

But now I have error:

июн 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

What's wrong?

Benny Bottema
  • 11,111
  • 10
  • 71
  • 96
Alexiuscrow
  • 776
  • 2
  • 15
  • 34
  • Are you using your actual details when you run this? – Reut Sharabani Jun 25 '15 at 15:41
  • possible duplicate of [How to resolve javax.mail.AuthenticationFailedException issue?](http://stackoverflow.com/questions/2047942/how-to-resolve-javax-mail-authenticationfailedexception-issue) – Krease Jun 25 '15 at 15:44

2 Answers2

1

You're using the wrong SMTP server. You need the GMail one.

"smtp.aol.com" -> "smtp.gmail.com"
artbristol
  • 32,010
  • 5
  • 70
  • 103
0

You are using an gmail account to connect to an aol smtp server !

Try with the good parameters ...

noelm
  • 1,252
  • 1
  • 8
  • 13