title: Spring JavaMailSenderImpl is not working with SSL
body: <p>Simple Java Mail client is working fine with an email server running on SSL. But the same server is not working when used from Spring JavaMailSenderImpl class. Also thunderbird works fine the mail server. But, spring has issues.</p>
  
  <p>Here is the original Java Code that works fine.</p>
  
  <pre><code>    final String username = "id@server.com";
      final String password = "password";
  
      Properties props = new Properties();
      props.put("mail.smtp.auth", "true");
      props.put("mail.smtp.starttls.enable", "true");
      props.put("mail.smtps.ssl.checkserveridentity", "true");
      props.put("mail.smtps.ssl.trust", "*");
      props.put("mail.smtp.host", "server.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("id@server.com"));
  
          message.setRecipients(  Message.RecipientType.TO, 
                                  InternetAddress.parse("id@gmail.com"));
  
          message.setSubject("Testing Subject");
          message.setText("Dear Mail Crawler, \n\n No spam to my email, please!");
  
          Transport.send(message);
  
          System.out.println("Done");
  
      } catch (MessagingException e) {
          throw new RuntimeException(e);
      }
  </code></pre>
  
  <p>here is the applicationContext.xml that contains the email configuration,</p>
  
  <pre><code>    &lt;bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"&gt;
          &lt;property name="javaMailProperties"&gt;
              &lt;props&gt;
                      &lt;prop key="mail.smtp.starttls.enable"&gt;true&lt;/prop&gt;
                      &lt;prop key="mail.smtp.auth"&gt;true&lt;/prop&gt;
                      &lt;prop key="mail.smtps.ssl.checkserveridentity"&gt;true&lt;/prop&gt;
                      &lt;prop key="mail.smtps.ssl.trust"&gt;*&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
          &lt;property name="username"  value="id@server.com" /&gt;
          &lt;property name="password"  value="password" /&gt;
          &lt;property name="port"&gt;&lt;value&gt;587&lt;/value&gt;&lt;/property&gt;
          &lt;property name="protocol"&gt;&lt;value&gt;smtp&lt;/value&gt;&lt;/property&gt;
          &lt;property name="host" value="server.com"/&gt;          
  &lt;/bean&gt;
  </code></pre>
  
  <p>What is the right way to configure Spring JavaMailSenderImpl ?</p>
  
  <p>Any help would be deeply appreciated.</p>