I am using Java Mail API Ver. 1.4.2 for sending out email in JSF 1.2-Spring based Web Application. I am using non secured SMTP connection for sending out a mail. This email configuration is working fine standalone. Also verified this utility using JUnit 4 test and I am able to send mail using non secure connection.
When I integrate this email module with main web application I am getting following exception at runtime while sending out a mail.
javax.mail.MessagingException: Exception reading response; nested exception is: javax.net.ssl.SSLHandshakeException: Remote host closed
connection during handshake at
com.sun.mail.smtp.SMTPTransport.readServerResponse(SMTPTransport.java:1764)
at
com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1523)
at
com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:453)
at javax.mail.Service.connect(Service.java:317) at
javax.mail.Service.connect(Service.java:176) at
javax.mail.Service.connect(Service.java:125) at
javax.mail.Transport.send0(Transport.java:194) at
javax.mail.Transport.send(Transport.java:124)
Verified this email module using secure SMTP connection and it's working fine.
Anyone having idea on this issue? Why non-secured SMTP connection not working in integration with Web Application?
Best Answer
I am using email module for both secured and non secured connections. In that following property was causing the issue : props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
Removed this property for non secured connections and now my non-secured SMTP connection is working in integration with Web Application.