javax authentication failed
<p>I am trying out an email app on android.I take the username and password first<br>
then on the next activity i take the recipiend address subject and msg and send the email.
I get the error <strong>JavaX authentication failure</strong>.Here is my Mail authentication and sending code.OnClick function of the send button calls this class</p>

<pre><code>public class MailHandler {
final String username;
final String password;
public MailHandler(String username,String password){
    this.username=username;
    this.password=password;

}

public void sendMail(String Sub,String msg,String sender,String cc,String to) {
    Properties props = new Properties();
    props.put("mail.smtp.auth", "true");
    props.put("mail.smtp.starttls.enable", "true");
    props.put("mail.smtp.host", "smtp.gmail.com");
    props.put("mail.smtp.port", "587");

    Session session = Session.getInstance(props,
      new javax.mail.Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication(username, password);
        }
      });

    try {

        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(sender));
        message.setRecipients(Message.RecipientType.TO,
            InternetAddress.parse(to));
        message.setSubject(Sub);
        message.setText(msg);

        Transport.send(message);

        System.out.println("Done");

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
}
}
</code></pre>
