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?