• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Confusion over SSL and TLS for sending mail thorugh JAVA Mail API

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ,
I dont have much idea about SSL/TLS so please correct me if I have put anything wrong . I am working on sending alert mails using JAVA Mail API using SMTP protocol . The mail server can be anything like gmail ,hotmail etc.

Now gmail and hotmail works over secure layer . From the net and the examples I have tried , I have found that HOTMAIL works only over TLS , SSL cant't be used for hotmail. While GMAIL works both over SSL and TLS

i.e for HOTMAIL only the following property setting works :-

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = new Properties();
props.put("mail.host","smtp.live.com");
props.put("mail.smtp.port", 587);
props.put("mail.smtp.auth", "true");



While for Gmail both sets of configuration works :-

1) Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = new Properties();
props.put("mail.host","smtp.gmail.com");
props.put("mail.smtp.port", 587);
props.put("mail.smtp.auth", "true");

2)
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = new Properties();
props.put("mail.host","smtp.gmail.com");
props.put("mail.smtp.port", 465);
props.put("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
props.put("mail.smtp.socketFactory.fallback", "false");
props.setProperty("mail.smtp.quitwait", "false");
props.put("mail.smtp.auth", "true");

Note the port has to be 587 in first set of configuration and 465 in second .

So I have the following doubts in my mind

1) I have read that TLS is a newer version of SSL but they are almost similar . What is exactly the difference between TLS and SSL . When specific cases each will be used (examples will be appreciated) .
2 ) Are all those mail servers which requires SSL autentication , will work with TLS .i.e like GMAIL ,all those servers which require SSL authentication ,the first set of configuration will work always ?
3) I have come across this post -> http://stackoverflow.com/questions/411331/using-javamail-with-tls which says :-

"props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");

is mandatory if the SMTP server uses SSL Authentication, like the GMail SMTP server does. However if the server uses Plaintext Authentication over TLS, it should not be present, because Java Mail will complain about the initial connection being plaintext. "

What is "Plaintext Authentication over TLS" and how is it different from SSL authentication ?

Thanks in advance






 
nikhil jai
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey ,
In my first post I forgot to specify the following property for hotmail and gmail first set of configuration to start TLS

props.put("mail.smtp.starttls.enable","true");

So for hotmail the properties are :-

Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = new Properties();
props.put("mail.host","smtp.live.com");
props.put("mail.smtp.port", 587);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable","true");

and for gmail the first set of configuration is :-
1) Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
Properties props = new Properties();
props.put("mail.host","smtp.gmail.com");
props.put("mail.smtp.port", 587);
props.put("mail.smtp.auth", "true");
props.put("mail.smtp.starttls.enable","true");
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See http://java.sun.com/products/javamail/FAQ.html#gmail, and pay close attention to the details of all the properties.
 
nikhil jai
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ulf ,
Thanks for your reply but actually I have already gone through this link .And whatever properties I have pasted here is only after testing . So could you please reply specifically to the questions I asked .
 
So you made a portal in time and started grabbing people. This tiny ad thinks that's rude:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic