email.message.EmailMessage

class email.message.EmailMessage(policy=default) If policy is specified (it must be an instance of a policy class) use the rules it specifies to udpate and serialize the representation of the message. If policy is not set, use the default policy, which follows the rules of the email RFCs except for line endings (instead of the RFC mandated \r\n, it uses the Python standard \n line endings). For more information see the policy documentation. This class is a subclass of Message. It adds the fo

email.iterators._structure()

email.iterators._structure(msg, fp=None, level=0, include_default=False) Prints an indented representation of the content types of the message object structure. For example: >>> msg = email.message_from_file(somefile) >>> _structure(msg) multipart/mixed text/plain text/plain multipart/digest message/rfc822 text/plain message/rfc822 text/plain message/rfc822 text/plain message/rfc822

email.iterators.typed_subpart_iterator()

email.iterators.typed_subpart_iterator(msg, maintype='text', subtype=None) This iterates over all the subparts of msg, returning only those subparts that match the MIME type specified by maintype and subtype. Note that subtype is optional; if omitted, then subpart MIME type matching is done only with the main type. maintype is optional too; it defaults to text. Thus, by default typed_subpart_iterator() returns each subpart that has a MIME type of text/*.

email.iterators.body_line_iterator()

email.iterators.body_line_iterator(msg, decode=False) This iterates over all the payloads in all the subparts of msg, returning the string payloads line-by-line. It skips over all the subpart headers, and it skips over any subpart with a payload that isn’t a Python string. This is somewhat equivalent to reading the flat text representation of the message from a file using readline(), skipping over all the intervening headers. Optional decode is passed through to Message.get_payload.

email.headerregistry.UnstructuredHeader

class email.headerregistry.UnstructuredHeader An “unstructured” header is the default type of header in RFC 5322. Any header that does not have a specified syntax is treated as unstructured. The classic example of an unstructured header is the Subject header. In RFC 5322, an unstructured header is a run of arbitrary text in the ASCII character set. RFC 2047, however, has an RFC 5322 compatible mechanism for encoding non-ASCII text as ASCII characters within a header value. When a value conta

email.headerregistry.SingleAddressHeader.address

address The single address encoded by the header value. If the header value actually contains more than one address (which would be a violation of the RFC under the default policy), accessing this attribute will result in a ValueError.

email.headerregistry.SingleAddressHeader

class email.headerregistry.SingleAddressHeader A subclass of AddressHeader that adds one additional attribute: address The single address encoded by the header value. If the header value actually contains more than one address (which would be a violation of the RFC under the default policy), accessing this attribute will result in a ValueError.

email.headerregistry.ParameterizedMIMEHeader.params

params A dictionary mapping parameter names to parameter values.

email.headerregistry.ParameterizedMIMEHeader

class email.headerregistry.ParameterizedMIMEHeader MOME headers all start with the prefix ‘Content-‘. Each specific header has a certain value, described under the class for that header. Some can also take a list of supplemental parameters, which have a common format. This class serves as a base for all the MIME headers that take parameters. params A dictionary mapping parameter names to parameter values.

email.headerregistry.MIMEVersionHeader.version

version The version number as a string, with any whitespace and/or comments removed.