Run folderlist.java 1.5.4 with Gmail SSL POP3

Q

How to run folderlist.java with javax.mail-1.5.4.jar with Gmail using SSL POP3 protocol? I have a valid Gmail email account.

✍: FYIcenter.com

A

folderlist.java in javamail-samples.zip can be used to retrieve mail folder information from Gmail mail server using SSL POP3 protocol. Here is an execution session of folderlist.java with javax.mail-1.5.4.jar:

fyicenter>cd \local\javamail-1.5.4\javamail-samples

local\javamail-1.5.4\javamail-samples>java -version
java version "1.8.0_45"

local\javamail-1.5.4\javamail-samples>javac -cp .;..\javax.mail-1.5.4.jar
   folderlist.java

local\javamail-1.5.4\javamail-samples>java -cp .;..\javax.mail-1.5.4.jar
   folderlist -D -L pop3s://john:password@pop.gmail.com

DEBUG: setDebug: JavaMail version 1.5.4
DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3s,com.sun.mail.pop3
.POP3SSLStore,Oracle]
DEBUG POP3: mail.pop3s.rsetbeforequit: false
DEBUG POP3: mail.pop3s.disabletop: false
DEBUG POP3: mail.pop3s.forgettopheaders: false
DEBUG POP3: mail.pop3s.cachewriteto: false
DEBUG POP3: mail.pop3s.filecache.enable: false
DEBUG POP3: mail.pop3s.keepmessagecontent: false
DEBUG POP3: mail.pop3s.starttls.enable: false
DEBUG POP3: mail.pop3s.starttls.required: false
DEBUG POP3: mail.pop3s.apop.enable: false
DEBUG POP3: mail.pop3s.disablecapa: false
DEBUG POP3: connecting to host "pop.gmail.com", port 995, isSSL true
+OK Gpop ready for requests from 71.174.32.174 b73mb203728752ybg
CAPA
+OK Capability list follows
USER
RESP-CODES
EXPIRE 0
LOGIN-DELAY 300
TOP
UIDL
X-GOOGLE-RICO
SASL PLAIN XOAUTH2 OAUTHBEARER
.
DEBUG POP3: authentication command trace suppressed
DEBUG POP3: authentication command failed
QUIT
+OK Bye b73mb203728752ybg
Exception in thread "main" javax.mail.AuthenticationFailedException: [AUTH] User
name and password not accepted.
        at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:209)
        at javax.mail.Service.connect(Service.java:364)
        at javax.mail.Service.connect(Service.java:245)
        at javax.mail.Service.connect(Service.java:194)
        at folderlist.main(folderlist.java:107)

The output shows that:

  • The javax.mail-1.5.4.jar contains JavaMail API classes like javax.mail.Service.
  • The javax.mail-1.5.4.jar contains POP3 implementation classes like com.sun.mail.pop3.POP3Store.protocolConnect.
  • JavaMail 1.5.4 supports SSL POP3 protocol.
  • pop.gmail.com server supports SSL POP3 protocol on port 995.
  • The authentication failed exception is expected, because the account name and password are invalid. If you provide your real gmail account name and password, you will get correct result.

 

msgsend sample Program with JavaMail 1.5.4

Run folderlist.java 1.5.4 with Gmail SSL IMAP

Download and Install JavaMail Library

⇑⇑ FAQ for JavaMail

2016-01-13, 2368🔥, 0💬