title: How to force JavaMailSenderImpl to use TLS1.2?
body: <p>Have a JDK7 app running on Tomcat and it does have the following env settings:</p>
  
  <pre><code>-Dhttps.protocols=TLSv1.1,TLSv1.2 
  </code></pre>
  
  <p>The above setting ensures that we don't use TLS 1.0 when connecting over HTTPS while making API calls etc.</p>
  
  <p>We also use the org.springframework.mail.javamail.<strong>JavaMailSenderImpl</strong> class to send outgoing SMTP email, and use these props:</p>
  
  <pre><code> mail.smtp.auth=false;mail.smtp.socketFactory.port=2525;mail.smtp.socketFactory.fallback=true;mail.smtp.starttls.enable=true
  </code></pre>
  
  <p>The problem is that the connection to the SMTP email server is failing when it's upgraded to TLS1.2. </p>
  
  <blockquote>
    <p>javax.net.ssl.SSLHandshakeException: Remote host closed connection
    during handshake</p>
  </blockquote>
  
  <p><strong>Is there a settings or code change that will force the TLS1.2 protocol?</strong></p>
  
  <p>I did some searching and it looks like these env settings are only for applet and web clients, not for server side apps</p>
  
  <pre><code>-Ddeployment.security.SSLv2Hello=false -Ddeployment.security.SSLv3=false -Ddeployment.security.TLSv1=false
  </code></pre>