JRE 1.5 VS. JRE 1.6 - Could not convert socket to TLS
I have an applet that is trying to send an email through an SMTP server. It works just fine 1.6 but on 1.5 it blows up and I'm kind of at the end of my rope. Any help here would be great.
I've had to set up the DummySSLSocketFactory as described in the JavaMail readme but still no luck on 1.5.
Here is the error:
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc.]
DEBUG SMTP: useEhlo true, useAuthtrue
DEBUG SMTP: trying to connect to host"mail.bluebottle.com", port 25, isSSLfalse
220 fe0.bluebottle.com ESMTP Sendmail 8.13.1/8.13.1; Thu, 28 Jun 2007 08:25:34 -0700
DEBUG SMTP: connected to host"mail.bluebottle.com", port: 25
EHLO CC-FRED
250-fe0.bluebottle.com Hello 207-174-73-129.officepartners.us [207.174.73.129] (may be forged), pleased to meet you
250-ENHANCEDSTATUSCODES
250-PIPELINING
250-8BITMIME
250-SIZE
250-DSN
250-AUTH LOGIN PLAIN
250-STARTTLS
250-DELIVERBY
250 HELP
DEBUG SMTP: Found extension"ENHANCEDSTATUSCODES", arg""
DEBUG SMTP: Found extension"PIPELINING", arg""
DEBUG SMTP: Found extension"8BITMIME", arg""
DEBUG SMTP: Found extension"SIZE", arg""
DEBUG SMTP: Found extension"DSN", arg""
DEBUG SMTP: Found extension"AUTH", arg"LOGIN PLAIN"
DEBUG SMTP: Found extension"STARTTLS", arg""
DEBUG SMTP: Found extension"DELIVERBY", arg""
DEBUG SMTP: Found extension"HELP", arg""
STARTTLS
220 2.0.0 Ready to start TLS
javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
java.net.SocketException: com.cc.util.controller.email.DummySSLSocketFactory
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1230)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:378)
at javax.mail.Service.connect(Service.java:275)
at javax.mail.Service.connect(Service.java:156)
at javax.mail.Service.connect(Service.java:176)
at com.cc.util.discovery.DiscoveryService.sendViaSMTP(DiscoveryService.java:422)
at com.cc.util.discovery.DiscoveryService.discoverSMTPService(DiscoveryService.java:378)
at com.cc.util.discovery.DiscoveryService.discoverPOP3Service(DiscoveryService.java:330)
at com.cc.util.discovery.DiscoveryService.checkEmailService(DiscoveryService.java:126)
at com.cc.applet.CCNonBlockingThread$1.run(CCNonBlockingThread.java:180)
at java.security.AccessController.doPrivileged(Native Method)
at com.cc.applet.CCNonBlockingThread.processEventData(CCNonBlockingThread.java:178)
at com.cc.applet.CCNonBlockingThread.run(CCNonBlockingThread.java:139)
Caused by: java.net.SocketException: com.cc.util.controller.email.DummySSLSocketFactory
at javax.net.ssl.DefaultSSLSocketFactory.createSocket(Unknown Source)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:249)
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1226)
... 12 more
Here is the code:
Properties props =new Properties();
props.put("mail.smtp.auth","true");
props.put("mail.smtp.host", smtpServer);
props.put("mail.smtp.starttls.enable","true");
// the line below is for java 1.5
java.security.Security.setProperty("ssl.SocketFactory.provider","com.cc.util.controller.email.DummySSLSocketFactory");
// these are for java 1.4
props.setProperty("mail.smtps.socketFactory.class","com.cc.util.controller.email.DummySSLSocketFactory");
props.setProperty("mail.smtps.socketFactory.fallback","false");
Session session = Session.getInstance(props,null);
session.setDebug(true);
// -- Create a new message --
Message msg =new MimeMessage(session);
// -- Set the FROM and TO fields --
msg.setFrom(new InternetAddress(from));
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to,false));
// -- Set the subject and body text --
msg.setSubject(subject);
msg.setText(body);
// -- Set some other header information --
msg.setHeader("X-Mailer","FuserDiscoveryProcess");
msg.setSentDate(new Date());
// -- Send the message --
Transport tr = session.getTransport("smtp");
tr.connect(username, password);
tr.sendMessage(msg,msg.getAllRecipients());
tr.close();
CCLogger.getLogger().log(Level.INFO,"Message sent OK.");

