folderlist Demo Program in JavaMail 1.4.7

Q

What is the folderlist.java in javamail1_4_7.zip?

✍: FYIcenter.com

A

folderlist.java in javamail1_4_7.zip is a demo program that lists information about the folders in an email account on a mail server.

folderlist.java is located at \local\javamail-1.4.7\demo\folderlist.java. Below is the usage description of folderlist.java:

Description:
	This program lists information about the folders in a Store.

Usage:
   java folderlist -L <url> -T <protocol> -H <host> -U <user> 
        -P <passwd> [-R <root>] [-r] [-v] [-D] <pattern>

Options:
   -L <url>  : URL of the Store. The URL should include
        the password as well (if needed).
        Example: "imap://john:password@mailstore.com"
   -T <protocol> : store protocol (Ex: "imap")
   -H <host> : hostname of store.
   -U <user> : username (if needed)
   -P <passwd>   : password (if needed)
   -R <root> : root of the folder hierarchy. This is optional. If
		  not present, listing starts from the default folder.
   -r       : list recursively - folder and all subfolders.
   -v       : verbose - show more info about each folder.
   -D       : Turn on session debugging
   <pattern>	: folders that match this pattern are listed. Use "*"
		  as wildcard to match everything.

Here is an execution session of folderlist.java:

fyicenter>cd \local\javamail-1.4.7\demo

local\javamail-1.4.7\demo>java -version 
java version "1.8.0_45"

local\javamail-1.4.7\demo>javac -cp ..\mail.jar folderlist.java

local\javamail-1.4.7\demo>java -cp .;..\mail.jar folderlist 
   -D -L imap://john:password@mailstore.com
DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.
IMAPStore,Oracle]
DEBUG IMAP: mail.imap.fetchsize: 16384
DEBUG IMAP: mail.imap.ignorebodystructuresize: false
DEBUG IMAP: mail.imap.statuscachetimeout: 1000
DEBUG IMAP: mail.imap.appendbuffersize: -1
DEBUG IMAP: mail.imap.minidletime: 10
DEBUG IMAP: trying to connect to host "mailstore.com", port 143, isSSL false
Exception in thread "main" javax.mail.MessagingException: Connection timed out:
connect;
  nested exception is:
        java.net.ConnectException: Connection timed out: connect
        at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:670)
        at javax.mail.Service.connect(Service.java:295)
        ...

The output shows that:

  • The mail.jar contains JavaMail API classes like javax.mail.Service.
  • The mail.jar contains IMAP implementation classes like com.sun.mail.imap.IMAPStore.protocolConnect.
  • The connection time out exception is expected, because mailstore.com is not valid mail server.

Back to FAQ for JavaMail API and Implementations.

2016-01-22, 1209👍, 0💬