Reputation: 1605
I'm making an application on android that retrieves emails from gmail accounts using JavaMail API. Here's my code:
Properties props = new Properties();
props.setProperty("mail.store.protocol", "imaps");
props.setProperty("mail.imaps.host", mailServer);
props.setProperty("mail.imaps.port", "993");
props.setProperty("mail.imaps.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
props.setProperty("mail.imaps.socketFactory.fallback", "false");
if (debug) Log.i("check","before session");
Session imapSession = Session.getDefaultInstance(props,null);
if (debug) Log.i("check","after session");
Whenever the code reaches the imapSession line, the application just crashes. In other words, it never reaches the last line. I've tried several mailServer strings:
imaps.gmail.com
imap.gmail.com
imaps.googlemail.com
imap.googlemail.com
and nothing seems to work. Is it the port? I'm sure I've added the right permissions, the error in the log cat doesn't mention the permissions anyways.
Another question where can I get such information for Gmail and other email servers?
Upvotes: 0
Views: 351
Reputation: 29971
Let's start by simplifying things. You've made several of the common JavaMail mistakes. Throw your code away and use the simple code in the JavaMail FAQ for connecting to Gmail. Then use the tips in the JavaMail FAQ for debugging any remaining problems. If you still have problems, post additional details here.
Upvotes: 1