Note that there are some explanatory texts on larger screens.

plurals
  1. POjavax.mail.AuthenticationFailedException: failed to connect, no password specified?
    primarykey
    data
    text
    <p>This program attempts to send e-mail but throws a run time exception:</p> <pre><code>javax.mail.AuthenticationFailedException: failed to connect, no password specified? </code></pre> <p>Why am I getting this exception when I have supplied the correct username and password for authentication?</p> <p>Both the sender and receiver have g-mail accounts. The sender and the receiver both have g-mail accounts. The sender has 2-step verification process disabled. </p> <p>This is the code:</p> <pre><code>import javax.mail.*; import javax.mail.internet.*; import java.util.*; class tester { public static void main(String args[]) { Properties props = new Properties(); props.put("mail.smtp.host" , "smtp.gmail.com"); props.put("mail.stmp.user" , "username"); //To use TLS props.put("mail.smtp.auth", "true"); props.put("mail.smtp.starttls.enable", "true"); props.put("mail.smtp.password", "password"); //To use SSL 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 = Session.getDefaultInstance( props , null); String to = "me@gmail.com"; String from = "from@gmail.com"; String subject = "Testing..."; Message msg = new MimeMessage(session); try { msg.setFrom(new InternetAddress(from)); msg.setRecipient(Message.RecipientType.TO, new InternetAddress(to)); msg.setSubject(subject); msg.setText("Working fine..!"); Transport transport = session.getTransport("smtp"); transport.connect("smtp.gmail.com" , 465 , "username", "password"); transport.send(msg); System.out.println("fine!!"); } catch(Exception exc) { System.out.println(exc); } } } </code></pre> <p>Even after giving the password I get the exception. Why is it not authenticating?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload