12.3 mimelib - A MIME handling package

The mimelib package is a library for managing MIME and other RFC822-based message documents. It subsumes most of the functionality in several older standard modules such as RFC 822, , , and other non-standard packages such as .

The primary distinguishing feature of mimelib is that it splits the parsing and generating of MIME documents, from the internal document object model representation of MIME. Applications using mimelib deal primarily with objects; you can add sub-objects to messages, remove sub-objects from messages, completely re-arrange the contents, etc. There is a separate parser class and a separate generator class which handles the transformation from flat text, to the object module, and then back to flat text again. There are also subclasses for some common MIME object types, and a few helper modules for extracting and parsing message field values.

The following subsections describe the functionality of the mimelib package. The ordering follows a progression common in applications: a MIME document is read as flat text from a file or standard input, the text is parsed to produce an object model representation of the MIME document, this object model is manipulated and queried, and finally the object model is rendered back into flat text. First though, there's an introduction to the basic mimelib.Message class.

It is perfectly feasible to create the object model out of whole cloth - i.e. completely from scratch. From there, the same progression can be taken. Also covered in the following subsections are the exception classes you might encounter while using mimelib, some auxiliary utilities, and a few examples.


Subsections
See About this document... for information on suggesting changes.