title: Using JavaMail with SSL and TLS
body: <p>I am using <a href="http://www.simplejavamail.org/#/about" rel="nofollow noreferrer" title="simple-java-mail">simple-java-mail</a> API which is a wrapper on top of JavaMail API.
  I am sending emails with my Gmail account credentials.
  I am mentioning what I am able to do and what not with this.</p>
  
  <p><strong><em>I am able to send emails perfectly with the following settings and properties.</em></strong></p>
  
  <pre><code>boolean enableSSL = true;
  props.put("mail.smtp.host", "smtp.gmail.com");
  props.put("mail.smtp.port", 465);
  
  props.put("mail.smtp.auth", "true"); //enable authentication
  props.put("mail.smtp.ssl.enable", enableSSL);
  If(enableSSL == true)
      transportStrategy = TransportStrategy.SMTP_SSL;
  </code></pre>
  
  <p>I am not able to send emails with plain SMTP.<br></p>
  
  <pre><code>    boolean enableSSL = false;
      props.put("mail.smtp.host", "smtp.gmail.com");
      props.put("mail.smtp.port", 25);
      if(enableSSL == false)
          transportStrategy = TransportStrategy.SMTP_PLAIN;
  </code></pre>
  
  <p>I am not able to send emails with TLS settings.<br></p>
  
  <pre><code>boolean enableSSL = true;
  boolean enableTLS = true;
  props.put("mail.smtp.host", "smtp.gmail.com");
  props.put("mail.smtp.port", 587);
  props.put("mail.smtp.auth", "true"); //enable authentication
  props.put("mail.smtp.ssl.enable", enableSSL);
  props.put("mail.smtp.starttls.enable", true);
  If(enableSSL == true &amp;&amp; enableTLS == true)
      transportStrategy = TransportStrategy.SMTP_TLS;
  </code></pre>
  
  <p>What should I do apart from these configuration properties?
  with settings smtp.gmail.com:25, code is not working at all. With smtp.gmail.com:465 and enableSSL = true, code is working like charm.</p>
  
  <p>But TLS is not working. I am attaching what error I am getting in all the 3 cases.</p>
  
  <p>Thanks,</p>