email.header.Header

class email.header.Header(s=None, charset=None, maxlinelen=None, header_name=None, continuation_ws=' ', errors='strict') Create a MIME-compliant header that can contain strings in different character sets. Optional s is the initial header value. If None (the default), the initial header value is not set. You can later append to the header with append() method calls. s may be an instance of bytes or str, but see the append() documentation for semantics. Optional charset serves two purposes: i

email.header.decode_header()

email.header.decode_header(header) Decode a message header value without converting the character set. The header value is in header. This function returns a list of (decoded_string, charset) pairs containing each of the decoded parts of the header. charset is None for non-encoded parts of the header, otherwise a lower case string containing the name of the character set specified in the encoded string. Here’s an example: >>> from email.header import decode_header >>> decod

email.generator.Generator.clone()

clone(fp) Return an independent clone of this Generator instance with the exact same options.

email.generator.BytesGenerator.write()

write(s) Write the string s to the underlying file object. s is encoded using the ASCII codec and written to the write method of the outfp outfp passed to the BytesGenerator‘s constructor. This provides just enough file-like API for BytesGenerator instances to be used in the print() function.

email.generator.DecodedGenerator

class email.generator.DecodedGenerator(outfp, mangle_from_=True, maxheaderlen=78, fmt=None) This class, derived from Generator walks through all the subparts of a message. If the subpart is of main type text, then it prints the decoded payload of the subpart. Optional _mangle_from_ and maxheaderlen are as with the Generator base class. If the subpart is not of main type text, optional fmt is a format string that is used instead of the message payload. fmt is expanded with the following keywo

email.generator.Generator.flatten()

flatten(msg, unixfrom=False, linesep=None) Print the textual representation of the message object structure rooted at msg to the output file specified when the Generator instance was created. Subparts are visited depth-first and the resulting text will be properly MIME encoded. Optional unixfrom is a flag that forces the printing of the envelope header delimiter before the first RFC 2822 header of the root message object. If the root object has no envelope header, a standard one is crafted.

email.generator.Generator

class email.generator.Generator(outfp, mangle_from_=True, maxheaderlen=78, *, policy=None) The constructor for the Generator class takes a file-like object called outfp for an argument. outfp must support the write() method and be usable as the output file for the print() function. Optional mangle_from_ is a flag that, when True, puts a > character in front of any line in the body that starts exactly as From, i.e. From followed by a space at the beginning of the line. This is the only gua

email.generator.Generator.write()

write(s) Write the string s to the underlying file object, i.e. outfp passed to Generator‘s constructor. This provides just enough file-like API for Generator instances to be used in the print() function.

email.errors.MessageParseError

exception email.errors.MessageParseError This is the base class for exceptions raised by the Parser class. It is derived from MessageError.

email.generator.BytesGenerator.flatten()

flatten(msg, unixfrom=False, linesep=None) Print the textual representation of the message object structure rooted at msg to the output file specified when the BytesGenerator instance was created. Subparts are visited depth-first and the resulting text will be properly MIME encoded. If the policy option cte_type is 8bit (the default), then any bytes with the high bit set in the original parsed message that have not been modified will be copied faithfully to the output. If cte_type is 7bit, t