title: Why I'm getting javax.mail.AuthenticationFailedException?
body: <p>Can someone tells me why the app throws this?</p>
  
  <pre><code>W/System.err: 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 javax.mail.Transport.send0(Transport.java:188)
  W/System.err:     at javax.mail.Transport.send(Transport.java:118)
          at com.example.**.Utils.SendMail.doInBackground(SendMail.java:71)
          at com.example.**.Utils.SendMail.doInBackground(SendMail.java:19)
          at android.os.AsyncTask$3.call(AsyncTask.java:378)
          at java.util.concurrent.FutureTask.run(FutureTask.java:266)
          at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
          at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
          at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
          at java.lang.Thread.run(Thread.java:919)
  
  
  </code></pre>
  
  <p>I'm trying to send a mail with javamail api.</p>
  
  <p>I want to mention that I checked on the mail account, less secure apps.</p>
  
  <p>This is the SendMail class</p>
  
  <pre><code>package com.example.****.Utils;
  
  
  import android.content.Context;
  import android.os.AsyncTask;
  import android.widget.Toast;
  
  import java.util.Properties;
  
  import javax.mail.Message;
  import javax.mail.MessagingException;
  import javax.mail.PasswordAuthentication;
  import javax.mail.Session;
  import javax.mail.Transport;
  import javax.mail.internet.InternetAddress;
  import javax.mail.internet.MimeMessage;
  
  
  public class SendMail extends AsyncTask&lt;Void, Void, Void&gt; {
  
    private Context context;
    private Session session;
  
  
    private String email;
    private String subject;
    private String message;
  
    public SendMail(Context context, String email, String subject, String message)
    {
        this.context = context;
        this.email = email;
        this.subject = subject;
        this.message = message;
    }
  
    @Override
      protected void onPreExecute() {
        super.onPreExecute();
        Toast.makeText(context, "Sending mail...", Toast.LENGTH_SHORT).show();
    }
  
    @Override
      protected void onPostExecute(Void aVoid)
    {
        super.onPostExecute(aVoid);
        Toast.makeText(context, "Message Sent", Toast.LENGTH_SHORT).show();
    }
  
    @Override
      protected Void doInBackground(Void... params) {
        Properties props = new Properties();
        props.put("mail.smtp.host", "smtp.gmail.com");
        props.put("mail.smtp.socketFactory.port", "465");
        props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        props.put("mail.smtp.auth", "true");
        props.put("mail.smtp.port", "465");
  
        session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {
            protected  PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(Config.EMAIL, Config.PASSWORD);
            }
        });
        try {
            MimeMessage mm = new MimeMessage(session);
            mm.setFrom(new InternetAddress(Config.EMAIL));
            mm.addRecipient(Message.RecipientType.TO, new InternetAddress(email));
            mm.setSubject(subject);
            mm.setText(message);
  
            Transport.send(mm);
        }
        catch (MessagingException e) {
            e.printStackTrace();
        }
        return null;
    }
  }
  
  </code></pre>
  
  <p>And here I'm using it</p>
  
  <pre><code>  String email = "******";
          String subject = "Activation";
          String message = "This User requires activation: " + "&lt;a href='http://localhost:80/approve/" +mAuth.getCurrentUser().getEmail() +"&gt; Click here &lt;/a&gt;";
  
          SendMail sm = new SendMail(this, email, subject,message);
          sm.execute();
  </code></pre>
  
  <p>I provided the right password, I checked that on my Google Account, it should be working
  can you please help me?</p>
  
  <p>Thank you in advance!</p>