email.message.Message
:表示 Email 消息使用
compat32
API
¶
The
Message
类非常类似于
EmailMessage
类,没有由该类添加的方法,且某些其它方法的默认行为稍有不同。这里还文档化了一些方法,虽然支持是通过
EmailMessage
类,不推荐除非正处理传统代码。
这 2 个类的哲学和结构在其它方面是相同的。
此文档描述的行为在默认 (对于
Message
) 策略
Compat32
。若打算使用其它策略,应使用
EmailMessage
类代替。
Email 包含 headers 和 payload 。Header 头必须是 RFC 5322 样式的名称和值,其中字段名称和值由冒号分隔。冒号不属于字段名称或字段值。负载可以是简单文本消息、二进制对象、或结构化的子消息序列 (每个子消息有自己的一组头和负载)。后一种类型的负载由拥有 MIME (多用途 Internet 邮件扩展) 类型的消息指示,譬如 multipart/* or message/rfc822 .
概念模型的提供通过
Message
object is that of an ordered dictionary of headers with additional methods for accessing both specialized information from the headers, for accessing the payload, for generating a serialized version of the message, and for recursively walking over the object tree. Note that duplicate headers are supported but special methods must be used to access them.
The
Message
pseudo-dictionary is indexed by the header names, which must be ASCII values. The values of the dictionary are strings that are supposed to contain only ASCII characters; there is some special handling for non-ASCII input, but it doesn’t always produce the correct results. Headers are stored and returned in case-preserving form, but field names are matched case-insensitively. There may also be a single envelope header, also known as the
Unix-From
header or the
From_
头。
payload
is either a string or bytes, in the case of simple message objects, or a list of
Message
objects, for MIME container documents (e.g.
multipart/*
and
message/rfc822
).
这里是方法对于
Message
类: