1

I am using javax mail to send mail from my activity. Here is my properties

    Properties properties = new Properties();
    properties.setProperty("mail.transport.protocol", "smtp");
    properties.setProperty("mail.host", mailhost);
    properties.put("mail.smtp.auth", "true");
    properties.put("mail.smtp.port", "995");
    properties.put("mail.smtp.socketFactory.port", "465");
    properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
    properties.put("mail.smtp.socketFactory.fallback", "false");
    properties.setProperty("mail.smtp.quitwait", "false");

While using this settings javax gives that error "javax.mail.AuthenticationFailedException".

And i must turn off the google security from this link!

But i dont want to turn off security service. Is there any way to use? I think problem is my properties, but i cant figure out.

Arda Kaplan
  • 1,720
  • 1
  • 15
  • 23

1 Answers1

1

For sending email using JavaMail you'll need to configure your Gmail account to enable less secure apps, or you'll need to use OAuth2 authentication (which is somewhat more complex).

Might be this also useful for you .For tutorial visit.or search java send email using oauth in google :)

Community
  • 1
  • 1
Anoop M Maddasseri
  • 10,213
  • 3
  • 52
  • 73