Laurent T
Laurent T

Reputation: 1098

Calling Store.connect in my servlet hangs

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", "[email protected]","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", "[email protected]","password");

Any thoughts??

Thanks

Upvotes: 0

Views: 567

Answers (1)

KumarM
KumarM

Reputation: 1699

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

Upvotes: 1

Related Questions