Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

connecting to gmail pop3 server

 
Bhavin Sanghani
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic