File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Other JSE/JEE APIs and the fly likes connecting to gmail pop3 server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "connecting to gmail pop3 server" Watch "connecting to gmail pop3 server" New topic

connecting to gmail pop3 server

Bhavin Sanghani
Ranch Hand

Joined: Dec 17, 2003
Posts: 67
Hi frnds,

I'm trying to connect with gmail pop server but it gives me following error...

DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Sun Microsystems, Inc]
POP3: connecting to host "", port 995
javax.mail.AuthenticationFailedException: EOF on socket
at com.sun.mail.pop3.POP3Store.protocolConnect(
at javax.mail.Service.connect(
at FetchMail.main(
Exception in thread "main"

Source code:

import java.util.*;
import javax.mail.*;

public class FetchMail {

public static void main(String[] args) throws MessagingException {
String host = "";
String username = username";
String password = "password";

Properties props = new Properties();

Session session = Session.getDefaultInstance(props, null);

Store store = session.getStore("pop3");
store.connect(host, 995, username, password);
Folder inbox=store.getDefaultFolder().getFolder("INBOX");;
Message[] msg=inbox.getMessages();
FetchProfile profile=new FetchProfile();

I wnat to ask can't we connect to public mail server using program?

D Rog
Ranch Hand

Joined: Feb 07, 2004
Posts: 472

You need to use SSL to connect to the server. Try a technique from this article:

Please share with us your results. I can need this also.

Retire your iPod and start with HD Android music player Kamerton | Minimal J2EE container is here | Light weight full J2EE stack | and build tool | Co-author of "Windows programming in Turbo Pascal"
I agree. Here's the link:
subject: connecting to gmail pop3 server
It's not a secret anymore!