에러내용 : 이메일주소를 넣고, 임시비밀번호를 메일로 발급받는 기능을 구현하던 중에 발생한 에러.
org.springframework.mail.MailSendException: Mail server connection failed; nested exception is javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate). Failed messages: javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate); message exceptions (1) are: Failed message 1: javax.mail.MessagingException: Could not convert socket to TLS; nested exception is: javax.net.ssl.SSLHandshakeException: No appropriate protocol (protocol is disabled or cipher suites are inappropriate)

 

해결방법 : root-context.xml에 다음 prop을 추가한다.
<prop key="mail.smtp.ssl.trust">smtp.gmail.com</prop> 
<prop key="mail.smtp.ssl.protocols">TLSv1.2</prop>
  • 나같은 경우, <prop key="mail.smtp.ssl.trust">smtp.gmail.com</prop> 는 생략해도 정상적으로 구동되었다.

 

적용한 코드

  <bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
    <property name="host" value="smtp.gmail.com" />
    <property name="port" value="587" />
    <property name="username" value="발송메일주소" />
    <property name="password" value="비밀번호" />
    <property name="javaMailProperties">
        <props>
            <prop key="mail.transport.protocol">smtp</prop>
            <prop key="mail.smtp.auth">true</prop>
            <prop key="mail.smtp.starttls.enable">true</prop>
            <prop key="mail.debug">true</prop>
            <!-- <prop key="mail.smtp.ssl.trust">smtp.gmail.com</prop> -->
            <prop key="mail.smtp.ssl.protocols">TLSv1.2</prop>
        </props>
    </property>
  </bean>