email.policy.EmailPolicy.refold_source

refold_source If the value for a header in the Message object originated from a parser (as opposed to being set by a program), this attribute indicates whether or not a generator should refold that value when transforming the message back into stream form. The possible values are: none all source values use original folding long source values that have any line that is longer than max_line_length will be refolded all all values are refolded. The default is long.

email.policy.EmailPolicy.fold_binary()

fold_binary(name, value) The same as fold() if cte_type is 7bit, except that the returned value is bytes. If cte_type is 8bit, non-ASCII binary data is converted back into bytes. Headers with binary data are not refolded, regardless of the refold_header setting, since there is no way to know whether the binary data consists of single byte characters or multibyte characters.

email.policy.EmailPolicy.header_source_parse()

header_source_parse(sourcelines) The implementation of this method is the same as that for the Compat32 policy.

email.policy.EmailPolicy.header_max_count()

header_max_count(name) Returns the value of the max_count attribute of the specialized class used to represent the header with the given name.

email.policy.EmailPolicy.header_store_parse()

header_store_parse(name, value) The name is returned unchanged. If the input value has a name attribute and it matches name ignoring case, the value is returned unchanged. Otherwise the name and value are passed to header_factory, and the resulting header object is returned as the value. In this case a ValueError is raised if the input value contains CR or LF characters.

email.policy.EmailPolicy.header_factory

header_factory A callable that takes two arguments, name and value, where name is a header field name and value is an unfolded header field value, and returns a string subclass that represents that header. A default header_factory (see headerregistry) is provided that understands some of the RFC 5322 header field types. (Currently address fields and date fields have special treatment, while all other fields are treated as unstructured. This list will be completed before the extension is mark

email.policy.EmailPolicy.header_fetch_parse()

header_fetch_parse(name, value) If the value has a name attribute, it is returned to unmodified. Otherwise the name, and the value with any CR or LF characters removed, are passed to the header_factory, and the resulting header object is returned. Any surrogateescaped bytes get turned into the unicode unknown-character glyph.

email.policy.EmailPolicy.fold()

fold(name, value) Header folding is controlled by the refold_source policy setting. A value is considered to be a ‘source value’ if and only if it does not have a name attribute (having a name attribute means it is a header object of some sort). If a source value needs to be refolded according to the policy, it is converted into a header object by passing the name and the value with any CR and LF characters removed to the header_factory. Folding of a header object is done by calling its fold

email.policy.default

email.policy.default An instance of EmailPolicy with all defaults unchanged. This policy uses the standard Python \n line endings rather than the RFC-correct \r\n.

email.policy.EmailPolicy.content_manager

content_manager An object with at least two methods: get_content and set_content. When the get_content() or set_content() method of a Message object is called, it calls the corresponding method of this object, passing it the message object as its first argument, and any arguments or keywords that were passed to it as additional arguments. By default content_manager is set to raw_data_manager. New in version 3.4.