Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaMail, ESMTP, problem with this server response: "+ stunnel"

843834Feb 15 2008 — edited Feb 21 2008
I need to send message through a STMP server I don't know much about. The server works fine, when using port 25. But I need to send mail through port 465. I've looked around the web, I've searched the forums, but found no solution.

I've identified, that the server uses some kind of strange "secure" connection. I was told, that is uses SSL, but when I use SMTPSSLTransport, it says the "Unrecognized SSL, plaintext connection?". So I am using the common Transport. This is my code:
            props.put("mail.transport.protocol","smtps");

            props.put("mail.smtp.host", smtpHost);
            props.put("mail.smtp.port", 465);            
            
            props.put("mail.smtps.starttls.enable","true");
            
            props.put("mail.smtps.ssl", "true");
            props.put("mail.smtps.socketFactory.port", 465);
            props.put("mail.smtps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

            Session session = Session.getDefaultInstance(props);
            session.setDebug(true);

            Transport transport = session.getTransport();
...
I am getting this output:
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "host name of the server", port 465, isSSL false
220 "host name of the server" ESMTP Sendmail 8.13.1/8.13.1; Fri, 15 Feb 2008 18:10:49 +0100
 + stunnelDEBUG SMTP: connected to host "host name of the server", port: 465

EHLO "my hostname"
DEBUG SMTP: bad server response:  + stunnel

HELO "my hostname"
250-"my hostname"
 WelcomeDEBUG SMTP: use8bit false
MAIL FROM:<joe@smith.com>
250 STARTTLS
220 Go ahead
RCPT TO:<jane@smith.com>
DEBUG SMTP: got response code 220, with response: 220 Go ahead

RSET
DEBUG SMTP: exception reading response: java.net.SocketException: Connection reset
javax.mail.MessagingException: Exception reading response;
  nested exception is:
        java.net.SocketException: Connection reset
I have no idea, what a stunnel is, but it is causing the problem, I think.

Does anybody have any ideas what can be wrong? Or does anyone know how to check the server setting? Or what properties can I try to set? (I've tried all possible options of the properties I am already setting in the code).
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 20 2008
Added on Feb 15 2008
11 comments
1,329 views