Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java mail store type "imap" vs "imaps"

I am using the following code to validate an email programatically.

Properties properties = new Properties();
Session emailSession = Session.getDefaultInstance(properties);
Store store = emailSession.getStore("imap");

store.connect(host, user, password);
if(store.isConnected()){
      System.out.println("true");
 }

currently it throws an exception

javax.mail.MessagingException: Connection dropped by server?;
nested exception is:
java.io.IOException: Connection dropped by server?
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:670)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at com.**.channel.type.IMAPValidator.fetch(IMAPValidator.java:23)
at com.**.channel.type.IMAPValidator.main(IMAPValidator.java:47)

However if i use

emailSession.getStore("imaps");

then it successfully connects to imap server of YAHOO.

What i know "imaps" stands for "secure".

What i dont know is why I cant simply use "imap"?

like image 886
Vivek Agrawal Avatar asked Jun 03 '15 07:06

Vivek Agrawal


1 Answers

Google does require a secure connection.

https://support.google.com/mail/troubleshooter/1668960?hl=en#ts=1665018%2C1665144

like image 72
Justin Tamblyn Avatar answered Oct 30 '22 11:10

Justin Tamblyn