I am trying to write a test case that connects to my MAP g mailbox and extracts all the letters from the inbox and processes them. But the store.connect statement (host, userName, password); not connected to the mail store. There is no error that I get when I trace the debug output, as shown below.
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 solve this problem using the code below.
MailSSLSocketFactory socketFactory= new MailSSLSocketFactory(); socketFactory.setTrustAllHosts(true); properties.put("mail.imaps.ssl.socketFactory", socketFactory); ......... Session session = Session.getDefaultInstance(properties);
source share