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).