Announcement Announcement Module
No announcement yet.
JavaMailSenderImpl halts when using SSL-secure server? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JavaMailSenderImpl halts when using SSL-secure server?

    Hi, I've been very pleased to work with spring javaMail classes and I got those working for simple non-secure smtp server quite easily. Finally when I started to move the component to production I just tought I'ld add some extra lines to applicationContext and it would work with TSL or SSL enabled server.

      <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="host"><value>mail.server.address</value></property>
        <property name="javaMailProperties">
            <prop key="mail.smtp.auth">true</prop>
        <property name="username"><value>username</value></property>
        <property name="password"><value>password</value></property>
        <property name="port"><value>465</value></property>
        <property name="protocol"><value>SSL</value></property>
    Unfortunately with this configuration it seems to lock when normal mail client is asked to verify server (accept the mac-address as a key). Is there something wrong with my configuration and is there any way to set timeout? At least I get no error messages in any logs.

    I also made the MailSender-bean MBean, I connected the bean with Jconsole and tried to form a connection to server. This way I got an error message, unfortunately, the almost nothing of the stacktrace fits into the error box of the Jconsole, but here is what it says:

    Problem Invoking dolt&#58; java.rmi.UnmarshalException&#58; Error unmarshaling return; nested exception is&#58;
    java.lang.ClassNotFoundException&#58; org.springframework.mail.MailSendException &#40;no security manager&#58; RMI class loader disabled&#41;
    I'd be very happy if you could offer me some insight.

  • #2
    Problem with SSL Secure mail server

    If anybody finds the solution to th above problem please post the details. I am facing the same problem.


    • #3
      SMTP mail and SSL

      Here's some tips on connecting to a SMTP mail server using SSL encryption.

      First off, you'll need to import the SSL key into a java keystore and tell your Java application or application server (eg., Tomcat) where the keystore file is. We can use OpenSSL to access a server's SSL certificate and save it in a file. Let me point you to some very good documentation provided by JIRA that outlines these steps in detail:

      Windows users can get OpenSSL from:

      Linux/Unix users probably already have OpenSSL or can get the source at:

      Next, you need to setup JavaMailSenderImpl to use the 'smtps' protocol. Notice that there are two extra properties that must be set and that I have specified a port number. You only need to specify a port number if you are connecting to a non-standard port for a given protocol. Refer to the Spring Framework documentation for examples of sending an email with Spring. That's it!

      JavaMailSenderImpl sender = new JavaMailSenderImpl();
      Properties mailProps = new Properties();
      mailProps.put("mail.smtps.auth", "true");
      mailProps.put("mail.smtp.starttls.enable", "true");


      • #4
        with the help of this code my exception changed from "Need to authenticate via SMTP first" to "Need to authenticate via POP3 first". Does anybody know the pop3 auth-property?