0

I am trying to get access my GMail inbox using IMAP and JavaMail in a servlet like this:

Session imapSession = this.getSession(true);
System.out.println("getting the store");
Store store = imapSession.getStore("imap");
System.out.println("connecting to the store");
store.connect("imap.gmail.com", "address@gmail.com","password");
System.out.println("getting the Sent folder");
Folder folder = store.getFolder("INBOX");
System.out.println("Opening the folder in a READ_WRITE mode");
folder.open(Folder.READ_WRITE);

The servlet hangs and does nothing more when calling store.connect("imap.gmail.com", "address@gmail.com","password");

Any thoughts??

Thanks

Laurent T
  • 1,070
  • 4
  • 13
  • 25

1 Answers1

1

Have you looked at these to find out how to connect to Gmail. There seems to be plethora of information available out there on this topic.

Using Javamail to connect to Gmail smtp server ignores specified port and tries to use 25

http://www.mkyong.com/java/javamail-api-sending-email-via-gmail-smtp-example/

Also I'd suggest that you first write a sample program - that can be run outside of your servlet code and container - get that to work and then integrate that with your servlet code. This might make it easier for your to develop and debug.

HTH, K

Community
  • 1
  • 1
KumarM
  • 1,669
  • 1
  • 18
  • 26