Reading Email


You need to read mail.


Use a JavaMail Store.


The JavaMail API is designed to be easy to use. Store encapsulates the information and access methods for a particular type of mail storage; the steps for using it are listed in the sidebar.

Sun provides a Store class for the IMAP transport mechanism, and optionally for POP3.[44] In these examples I use the Unix mbox protocol[45] (when I started with Unix there was no POP3 protocol; it was traditional to access your mail spool file directly on a server). However, you could use all these programs with the POP or IMAP stores just by passing the appropriate protocol name where “mbox” appears in the following examples. I’ve tested several of the programs using Sun’s POP store and several POP servers (CUCIpop and PMDF).

I delete most of the email I get on one of my systems, so there were only two messages to be read when I ran my first "mailbox lister” program:$ java MailLister mbox localhost ...

Get Java Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.