I had a weird error today when trying to connect to my server’s postfix mail server. It’s weird because i never had this kind of error when connecting to Google Mail server. This is the error that i see on postfix’s log.
Mar 26 01:50:19 localhost postfix/smtpd[24907]: connect from localhost[127.0.0.1] Mar 26 01:50:19 localhost postfix/smtpd[24907]: setting up TLS connection from localhost[127.0.0.1] Mar 26 01:50:19 localhost postfix/smtpd[24907]: SSL_accept error from localhost[127.0.0.1]: 0 Mar 26 01:50:19 localhost postfix/smtpd[24907]: warning: TLS library problem: 24907:error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown:s3_pkt.c:1193:SSL alert number 46: Mar 26 01:50:19 localhost postfix/smtpd[24907]: lost connection after STARTTLS from localhost[127.0.0.1] Mar 26 01:50:19 localhost postfix/smtpd[24907]: disconnect from localhost[127.0.0.1]
This is my email configuration on Spring’s applicationContext.xml.
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="localhost"/> <property name="port" value="25"/> <property name="username" value="admin@whatever.com"></property> <property name="password" value="password"></property> <property name="javaMailProperties"> <props> <prop key="mail.smtp.auth">true</prop> <prop key="mail.smtp.starttls.enable">true</prop> </props> </property> </bean>
After googling for a while, i found out that somehow the error happen because of TLS problem. The workaround is actually easy, i disabled the starttls property on bean mailSender.
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl"> <property name="host" value="localhost"/> <property name="port" value="25"/> <property name="username" value="admin@whatever.com"></property> <property name="password" value="password"></property> <property name="javaMailProperties"> <props> <prop key="mail.smtp.auth">true</prop> <prop key="mail.smtp.starttls.enable">false</prop> </props> </property> </bean>