jQuery in Action, 3rd edition
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
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 "pop.gmail.com", port 995
javax.mail.AuthenticationFailedException: EOF on socket
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:104)
at javax.mail.Service.connect(Service.java:234)
at FetchMail.main(FetchMail.java:17)
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 = "pop.gmail.com";
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: http://aspose.com/file-tools
subject: connecting to gmail pop3 server
It's not a secret anymore!