3
votes

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?

1
Does your remote host accept from the server you are sending from? Have you tried a bare-bones attempt to e-mail via Java from the server, but external to your web application? You say it's working fine standalone and you verified with JUnit, but is that standalone from your development station or standalone from the server itself?JoshDM
Also what port are you trying against, the SSL port or the non-SSL port? Default is port 25.JoshDM
Following property was causing the issue : props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); Removed this for non secured connections.mmodi

1 Answers

0
votes

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.