Note that there are some explanatory texts on larger screens.

plurals
  1. POEmail Client in java
    primarykey
    data
    text
    <p>try { Properties props = new Properties(); props.put("mail.smtp.starttls.enable", "true"); props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.smtp.host", "smtp.gmail.com"); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); props.put("mail.smtp.socketFactory.port", "587"); props.put("mail.smtp.socketFactory.fallback", "false"); props.setProperty("mail.user", "username"); props.setProperty("mail.password", "password");</p> <pre><code>Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() { protected PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication("username","password"); } }); session.setDebug(true); MimeMessage msg = new MimeMessage(session); InternetAddress addressFrom = new InternetAddress(from); msg.setFrom(addressFrom); msg.addRecipient(Message.RecipientType.TO,new InternetAddress(" Recipient mail id ")); msg.setSubject(subject); Transport transport = session.getTransport(); transport.connect(); transport.sendMessage(msg,msg.getRecipients(Message.RecipientType.TO)); transport.close(); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } </code></pre> <p>I am using the above code to send email to a gmail account. I have set the smtp host value (smtp.gmail.com)and port (465) in the properties. But the email is not sent and my app got stuck for long time. After that i am getting an error like given below</p> <p>"javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port: 465, response: -1"</p> <p>Can anyone tell what is the reason and how to resolve this issue? </p>
    singulars
    1. This table or related slice is empty.
    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.
    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