I want to receive emails using imap trough secure connection. I implemented it using using javax.mail api. But there are different server configurations. As I found
1) store = session.getStore(imaps);
store.connect(imap.gmail.com, username, password)
Which make 'isSSL' true and use port 993 which is secure port to connect in javax.mail. Following configuration also prove secure connection through 993 port.
2) properties.put("mail.imap.host", imap.gmail.com);
properties.put("mail.imap.port", "993");
Properties.put("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
properties.setProperty("mail.imap.socketFactory.fallback","false");
Properties.setProperty("mail.imap.socketFactory.port", 993);
These two methods work fine. Can you please tell me what is different between these two and what is the correct way to receive messages through secure connection. Futher I found; "mail.imap.ssl.enable" and "mail.imap.starttls.enable. Can you tell me whether i needed these two also.