Chapter 7. Mailbox Formats

In this chapter:

  • mbox

  • MH

  • Maildir

Up to this point, everything we have covered has involved standards: standard formats or proposed standards. In the next few chapters, we will introduce more standards for mail-related protocols. There is, however, nothing standard about mailbox formats.

Existing standards leave the details like mailbox formats to implementations. This is probably a good thing but has lead to a plethora of formats in common use. As we shall see, each of them has particular advantages and disadvantages.

If you are creating a program that reads or writes an electronic mailbox, you can either choose one of the formats described in this chapter or create your own. Although none of the formats listed here have the official “standard” stamp of approval, some of them are in such wide use as to be de facto standards, and one should have a good reason not to use them. In fact, using one of these formats in your code will allow others to parse your mailboxes, which most would consider to be a good thing.

If you’re writing scripts to operate on existing mailboxes, you will have to understand the existing formats since you will have to live with what you have. Take heart, though, since these formats are very simple to understand.

This chapter will look at three common mailbox formats and some of their common variations. Each of them has a particular reason for being.

Mailbox formats are generally of two types: one concatenates messages in a single file to make ...

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.