Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't authenticate with Hotmail #6

Open
GoogleCodeExporter opened this issue Mar 31, 2016 · 1 comment
Open

Can't authenticate with Hotmail #6

GoogleCodeExporter opened this issue Mar 31, 2016 · 1 comment

Comments

@GoogleCodeExporter
Copy link

I cannot authenticate with a hotmail address using JavaMail. I verified that I 
can connect to smtp.live.com via telnet port 587. 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.OpenSSLSocketFactoryImpl@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 the code to recreate the issue.
Thanks in advance,

J

String host = "smtp.live.com"; 

String username = foo@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(); 

} 

} 

Original issue reported on code.google.com by [email protected] on 3 Oct 2010 at 9:45

@GoogleCodeExporter
Copy link
Author

Here are the properties I used to get smtp.live.com to work with 
javamail-android:

props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable", "true");
props.put("mail.smtp.port", _port);  //This was 25
props.put("mail.smtp.socketFactory.port", _sport);  //This was 587
props.put("mail.smtp.socketFactory.fallback", "false");

I was using a GMail sample to do it and found that this line was interfering 
with the smtp.live.com mail sending, so I commented it out:
//props.put("mail.smtp.socketFactory.class",
//  "javax.net.ssl.SSLSocketFactory");

If I didn't comment it out, this is the error message I'd get

javax.mail.MessagingException: 530 5.7.0 Must issue a STARTTLS command first



Original comment by [email protected] on 23 Apr 2011 at 1:19

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant