Results 1 to 1 of 1
- 07-29-2010, 02:06 PM #1
Member
- Join Date
- Jul 2010
- Posts
- 6
- Rep Power
- 0
JavaMail gmail imap error: "Host is unresolved: imaps.gmail.com:993."
I need to write an app that periodically parses the contents of gmail messages. I have been through the JavaMail FAQ and I have looked at a number of examples in the JavaMail download package but have been unable to get this to work. The code below currently causes the following gmail error:
Host is unresolved: imaps.gmail.com:993
Host is unresolved: imap.gmail.com:143
Java Code:public class GMailReader extends javax.mail.Authenticator { private String mailhost = "imaps.gmail.com"; private String user; private String password; private Session session; public GMailReader(String user, String password) { this.user = user; this.password = password; Properties props = new Properties(); props.setProperty("mail.transport.protocol", "imaps"); props.setProperty("mail.imaps.host", mailhost); props.put("mail.imaps.auth", "true"); props.put("mail.imaps.port", "993"); props.put("mail.imaps.socketFactory.port", "993"); props.put("mail.imaps.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.imaps.socketFactory.fallback", "false"); props.setProperty("mail.imaps.quitwait", "false"); session = Session.getDefaultInstance(props, this); } public synchronized Message[] readMail() throws Exception { try { Store store = session.getStore("imaps"); store.connect("imaps.gmail.com", user, password); Folder folder = store.getFolder("INBOX"); folder.open(Folder.READ_ONLY); Message[] msgs = folder.getMessages(1, 10); FetchProfile fp = new FetchProfile(); fp.add(FetchProfile.Item.ENVELOPE); folder.fetch(msgs, fp); return msgs; } catch (Exception e) { Log.e("readMail", e.getMessage(), e); return null; } } }
Similar Threads
-
javax.mail.MessagingException: Could not connect to SMTP host: smtp.gmail.com, port:
By nikunj.prmr@gmail.com in forum Advanced JavaReplies: 2Last Post: 08-24-2011, 05:32 PM -
error in smpt.gmail.com host
By kib_tse in forum NetworkingReplies: 15Last Post: 03-10-2011, 07:25 PM -
JavaMail and Gmail
By khushbu in forum NetBeansReplies: 14Last Post: 05-23-2010, 06:49 PM -
530 5.7.0 Authentication Required - JavaMail gmail
By simon in forum Advanced JavaReplies: 1Last Post: 07-15-2007, 12:52 AM
Bookmarks