java mail store type “imap” vs “imaps”

僤鯓⒐⒋嵵緔 提交于 2019-12-23 07:46:33

问题


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"?


回答1:


Google does require a secure connection.

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



来源:https://stackoverflow.com/questions/30613622/java-mail-store-type-imap-vs-imaps

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!