Chapter 4. Creating MIME-Compliant Messages

In this chapter:

  • The Minimal MIME Message

  • Multipart Messages

  • Nested Body Parts

  • A Few Interesting MIME Types

  • MIME Message Creation Gotchas

Now comes the fun part—actually creating MIME-compliant messages. This chapter describes the procedures for creating simple and complex MIME-compliant messages and provides numerous examples. It also shows the use of some less-understood but useful MIME types.

It should be made clear that MIME implementations vary greatly in their adherence to the standard or their degree of implementation. Since the most common use of MIME is to attach binary files to text email, some MIME parsers in MUAs may presume this format (that is, a multipart message, or a message layed out as multipart even though it has only one message part). The simplest MIME message presented here is correct but may break some half-baked implementations. It is shown here primarily as a step along the path to understanding. As always, a little caution goes a long way.[9]

[9] Or to be less generous and quote Robert Heinlein: “Never underestimate human stupidity.” If Robert had been a programmer, perhaps he would have added “especially your own.”

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.