store.connect(主机,用户名,密码)未连接到我的Gmail [英] store.connect(host,username,password) is not Connecting to my gmail

查看:127
本文介绍了store.connect(主机,用户名,密码)未连接到我的Gmail的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个连接到MAP g邮件收件箱并从收件箱中检索所有邮件并对其进行处理的测试用例,但是语句store.connect(host,userName,password);未连接到g邮件存储.跟踪调试输出时没有错误,就像波纹管

I am trying to write a test case which connect to I MAP g mail inbox and retrieve all mails from inbox and process them But the statement store.connect( host, userName, password ) ; is not connecting to g mail store. No error i am getting when i trace debug output it is like bellow

DEBUG: setDebug: JavaMail version 1.4.6
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle]
DEBUG IMAPS: mail.imap.fetchsize: 16384
DEBUG IMAPS: mail.imap.ignorebodystructuresize: false
DEBUG IMAPS: mail.imap.statuscachetimeout: 1000
DEBUG IMAPS: mail.imap.appendbuffersize: -1
DEBUG IMAPS: mail.imap.minidletime: 10
DEBUG IMAPS: enable STARTTLS
DEBUG IMAPS: trying to connect to host "imap.gmail.com", port 993, isSSL true 

我使用以下代码解决了这个问题.

I resolve this problem with below code.

MailSSLSocketFactory socketFactory= new MailSSLSocketFactory();
        socketFactory.setTrustAllHosts(true);
        properties.put("mail.imaps.ssl.socketFactory", socketFactory);
.........
Session session = Session.getDefaultInstance(properties);

推荐答案

JavaMail常见问题解答具有有关调试连接问题的提示.

The JavaMail FAQ has tips for debugging connection problems.

这篇关于store.connect(主机,用户名,密码)未连接到我的Gmail的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆