The email package was originally prototyped as a separate library
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:
- messageFromString() has been renamed to message_from_string().
- messageFromFile() has been renamed to message_from_file().
The Message class has the following differences:
- The method asString() was renamed to as_string().
- The method ismultipart() was renamed to is_multipart().
- The get_payload() method has grown a decode optional
- The method getall() was renamed to get_all().
- The method addheader() was renamed to add_header().
- The method gettype() was renamed to get_type().
- The methodgetmaintype() was renamed to get_main_type().
- The method getsubtype() was renamed to get_subtype().
- The method getparams() was renamed to get_params().
Also, whereas getparams() returned a list of strings, get_params() returns a list of 2-tuples, effectively the key/value
pairs of the parameters, split on the "=" sign.
- The method getparam() was renamed to get_param().
- The method getcharsets() was renamed to get_charsets().
- The method getfilename() was renamed to get_filename().
- The method getboundary() was renamed to get_boundary().
- The method setboundary() was renamed to set_boundary().
- The method getdecodedpayload() was removed. To get similar
functionality, pass the value 1 to the decode flag of the get_payload() method.
- The method getpayloadastext() was removed. Similar functionality
is supported by the DecodedGenerator class in the email.Generator module.
- The method getbodyastext() was removed. You can get similar
functionality by creating an iterator with typed_subpart_iterator()
in the email.Iterators
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
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()
The following modules and classes have been changed:
mimelib provided some utility functions in its address
and date modules. All of these functions have been moved to the email.Utils module.
MsgReader class/module has been removed. Its functionality is most closely
supported in the body_line_iterator() function in the email.Iterators module.
- ... notification12.3
- Delivery Status Notifications (DSN) are defined in RFC 1894.