Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

accessing gmail via pop3s or imaps

843834Dec 6 2007 — edited Dec 10 2007
I am experiencing problems accessing gmail with java mail.

I've searched, reviewed, and tried many of the tips on this forum without success. I am sending this email in case someone can spot something either unique or wrong in what I am doing. Note I am making the assumption, and asking for verification, that if a local thunderbird client can access gmail via pop in my local environment, then java mail should, if configured properly, be able to as well.

I have 2 gmail accounts, both configured for pop and imap.
I use a thunderbird client to successfully access both accounts with pop (I have not configured thunderbird for nor tried imap access.)
I am only using one account for java mail testing.
I run zoneAlarm Pro.

I am running an up-to-date version of windows XP-Pro.
javac -version 1.6.0_02
java -version 1.6.03 (build b05 mixed mode)
javamail 1.4.1

I copied the demo directory into a parallel directory named emailTest to allow local changes while still having local access to the original code.

All of the following commands happen in the emailTest folder.

javac -classpath ../mail.jar msgshow.java
java -cp ./;../mail.jar msgshow -T pop3s -H pop.google.com -U USER -P PASSWORD -v -D

where USER and PASSWORD are for an active gmail account - such as USER@gmail.com with password PASSWORD

This is sysout
DEBUG: setDebug: JavaMail version 1.4.1
DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3.POP3SSLStore,Sun Microsystems, Inc]
DEBUG POP3: connecting to host "pop.google.com", port 995, isSSL true
Oops, got exception! Connect failed

this is syserr
javax.mail.MessagingException: Connect failed;
nested exception is:
java.net.ConnectException: Connection refused: connect
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:161)
at javax.mail.Service.connect(Service.java:288)
at msgshow.main(msgshow.java:162)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.connect(Unknown Source)
at com.sun.net.ssl.internal.ssl.BaseSSLSocketImpl.connect(Unknown Source)
at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:233)
at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
at com.sun.mail.pop3.Protocol.<init>(Protocol.java:94)
at com.sun.mail.pop3.POP3Store.getPort(POP3Store.java:214)
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:157)
... 2 more
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 7 2008
Added on Dec 6 2007
11 comments
1,881 views