Chapter 17. Watching an IMAP Mailbox

In this chapter:

  • Designing JBiff

  • Creating JBiff

  • Extending Jiff

Perl is not the only language of choice these days. Java is a simple, cleanly structured language that makes object-oriented programming much more pleasant than most older alternatives. The Java Mail API makes email programming a breeze, as we have seen at the tail end of Chapter 15, Creating and Sending a Multipart Mail Message. In this chapter, we will try a more complicated script to monitor an IMAP mailbox and present its status graphically. [25]

Most Unix users will be familiar with the handy utility biff, which informs a user when she has mail in her mailbox. Graphically, biff variants are usually implemented with an icon of a mailbox, whose flag is raised or lowered as appropriate. This utility watches the user’s system mailbox on the local machine, normally in /var/spool/mail.

A Java version of biff has several advantages: it has the capability of watching multiple mailboxes in addition to the Inbox. It watches remote IMAP and POP mailboxes, too. Its user interface can be as simple or as complex as we desire. Thus, JBiffis born.

This is not an introduction to object-oriented programming; there are many good books for that. Indeed, you should not take the short script presented here as being indicative of the beautiful OO style. However, the major concepts required to effectively use the Java Mail API are presented.

[25] My sincere thanks to Chris Ryan (

Get Programming Internet Email now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.