I am having trouble sending emails from a hotmail address using
JavaMail. I verified that I can connect to smtp.live.com via telnet
port 587. The interesting thing (to me) is if I change:
host = "smtp.gmail.com"
t.connect(host, username, password);
It connects to Gmail just fine on the default port and sends an
email.
But if I change the code to:
host = "smtp.live.com"
t.connect(host,587, username, password);
It gives me the following error:
javax.mail.MessagingException: Could not connect to SMTP host:
smtp.live.com, port: 587;
nested exception is:
java.io.IOException: SSL handshake failure: Failure in SSL library,
usually a protocol error
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
(external/openssl/ssl/s23_clnt.c:604 0xaf076228:0x00000000)
With session.setDebug(true) I get this info:
09-15 01:57:37.280: INFO/System.out(720): DEBUG: getProvider()
returning
javax.mail.Provider[TRANSPORT,smtps,com.sun.mail.smtp.SMTPSSLTransport,Sun
Microsystems, Inc.,1.4.1]
09-15 01:57:37.300: INFO/System.out(720): DEBUG SMTP: useEhlo true,
useAuth true
09-15 01:57:37.310: INFO/System.out(720): DEBUG SMTP: trying to
connect to host "smtp.live.com", port 587, isSSL true
09-15 01:57:37.330: INFO/SSLSocketFactory(720): Using factory
org.apache.harmony.xnet.provider.jsse.opensslsocketfactoryi...@4007ed70
09-15 01:57:37.490: DEBUG/NativeCrypto(720): SSL_OP_NO_SSLv3 is set
09-15 01:57:37.538: ERROR/NativeCrypto(720): Unknown error 1 during
connect
Looks like Hotmail isn't playing nice with OpenSSL. Does anyone have
a solution for this?
Below is my code in...just in case it helps.
Thanks in advance,
J
String host = "smtp.live.com";
String username = f...@hotmail;
String password = "**";
Transport t = null;
Properties props = new Properties();
props.put("mail.smtps.auth", "true");
//props.put("mail.smtp.socketFactory.class",
"javax.net.ssl.SSLSocketFactory");
Session session = Session.getInstance(props);
session.setDebug(true);
try{
MimeMessage msg = new MimeMessage(session);
msg.setSubject("Testing SMTP-SSL");
msg.setContent("This is a test", "text/plain");
msg.setFrom(new InternetAddress(username));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(username, false));
t = session.getTransport("smtps");
t.connect(host,587, username, password);
t.sendMessage(msg, msg.getAllRecipients());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
try {
t.close();
} catch (MessagingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en