0

I'm trying to send an email with using javax.mail but the line of transport.connect() is cause to javax.mail.AuthenticationFailedException.

public void sendEmail() throws AddressException, MessagingException {
    Transport transport = mailSession.getTransport("smtp");
    transport.connect(emailHost, fromEmail, fromPassword);
    Log.i("GMail","allrecipients: "+emailMessage.getAllRecipients());
    transport.sendMessage(emailMessage, emailMessage.getAllRecipients());
    transport.close();
    Log.i("GMail", "Email sent successfully.");
}
Itzik Shachar
  • 744
  • 5
  • 16
  • 2
    The server you're specifying in emailHost is rejecting the attempt to connect to it. Probably a bad username/password, but it could be something more complex. – Gabe Sechan May 29 '17 at 18:10
  • https://stackoverflow.com/questions/18778240/solve-error-javax-mail-authenticationfailedexception – Jorry Lubenova May 29 '17 at 18:15
  • Possible duplicate of [Solve error javax.mail.AuthenticationFailedException](https://stackoverflow.com/questions/18778240/solve-error-javax-mail-authenticationfailedexception) – Marged May 29 '17 at 18:28
  • it's not working – Serdar Yazici May 29 '17 at 18:31
  • Did you enable less secure apps, as described in the link above? If so, post the [JavaMail debug output](https://javaee.github.io/javamail/FAQ#debug). – Bill Shannon May 30 '17 at 06:30

0 Answers0