This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "connecting to gmail pop3 server" Watch "connecting to gmail pop3 server" New topic
Author

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
S: EOF
C: QUIT
S: EOF
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);
session.setDebug(true);

Store store = session.getStore("pop3");
store.connect(host, 995, username, password);
Folder inbox=store.getDefaultFolder().getFolder("INBOX");
inbox.open(Folder.READ_ONLY);
Message[] msg=inbox.getMessages();
FetchProfile profile=new FetchProfile();
profile.add(FetchProfile.Item.ENVELOPE);
inbox.fetch(msg,profile);
System.out.println(msg);
}
}



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

-bhavin
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:
http://www.javaworld.com/javatips/jw-javatip115.html

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
 
Similar Threads
Java Mail pop3 listener
JavaMail EOf on socket
Problem with Retriving mails from INBOX
Reading Java Mail
Couldn't get Message List: Connect failed?!