Search code examples
javaspringjakarta-mail

No such provider for https after Spring context upgrade


I am working on Spring MVC application, which is sending email using Spring JavaMail package.i.e.

org.springframework.mail.javamail.JavaMailSenderImpl

I have the properties during bean creation

<bean id="mailInfo" class="org.springframework.mail.javamail.JavaMailSenderImpl">
        <property name="port" value="25" />
        <!-- <property name="username" value="[email protected]" /> -->
        <property name="username" value="[email protected]" />
        <property name="password" value="xxxxx" />
        <property name="javaMailProperties">
            <props>
                <prop key="mail.transport.protocol">https</prop>
                <prop key="mail.smtp.host">hostname</prop>
                <prop key="mail.smtps.auth">true</prop>
                <prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
                <prop key="mail.smtp.socketFactory.port">25</prop>
                <prop key="mail.debug">true</prop>
                <prop key="mail.smtp.ssl.enable">false</prop>
                <prop key="mail.smtp.ssl.trust">true</prop>
                <prop key="mail.smtp.starttls.enable">true</prop>
                <prop key="mail.smtp.socketFactory.fallback">true</prop>
            </props>
        </property>
    </bean>

It was working fine. I am adding the caching functionality using Ehcache 2.8.1. I had to upgrade the spring-context to atleast 3.1 version. But, when I upgraded the spring-context-support to 3.2.3. It started to throw the exception below.

ERROR MailServiceImpl:130 - MailSendException:Mail server connection failed; nested    
exception is javax.mail.NoSuchProviderException: No provider for https.
Failed messages: javax.mail.NoSuchProviderException: No provider for https

I have been working on this issue for more than a day. Can someone please help me understand the problem? I am assuming that this would be a classpath issue. But, how can i solve this kind of issues. Please help.


Solution

  • The transport should probably be "smtp" not "https" (I mean on port 25..)

    As far as I know, there's no "https" mail transport provider, maybe the java mail API used before and after upgrade is not the same and the old one did a fallback to "smtp".

    See also: http://docs.oracle.com/javaee/7/api/javax/mail/package-summary.html