The email package was originally prototyped as a separate library called mimelib. Changes have been made so that method names are more consistent, and some methods or modules have either been added or removed. The semantics of some of the methods have also changed. For the most part, any functionality available in mimelib is still available in the email package, albeit often in a different way. Backward compatibility between the mimelib package and the email package was not a priority.
Here is a brief description of the differences between the mimelib and the email packages, along with hints on how to port your applications.
Of course, the most visible difference between the two packages is that the package name has been changed to email. In addition, the top-level package has the following differences:
The Message class has the following differences:
The Parser class has no differences in its public interface. It does have some additional smarts to recognize message/delivery-status type messages, which it represents as a Message instance containing separate Message subparts for each header block in the delivery status notification7.4.
The Generator class has no differences in its public interface. There is a new class in the email.generator module though, called DecodedGenerator which provides most of the functionality previously available in the Message.getpayloadastext() method.
The following modules and classes have been changed:
Image
class/module has been renamed to
MIMEImage
. The _minor argument has been renamed to
_subtype.
Text
class/module has been renamed to
MIMEText
. The _minor argument has been renamed to
_subtype.
MessageRFC822
class/module has been renamed to
MIMEMessage
. Note that an earlier version of
mimelib called this class/module RFC822
, but
that clashed with the Python standard library module
rfc822 on some case-insensitive file systems.
Also, the MIMEMessage class now represents any kind of MIME message with main type message. It takes an optional argument _subtype which is used to set the MIME subtype. _subtype defaults to rfc822.
mimelib provided some utility functions in its address and date modules. All of these functions have been moved to the email.utils module.
The MsgReader
class/module has been removed. Its functionality
is most closely supported in the body_line_iterator()
function in the email.iterators module.