Expand description
RFC 5322 message composition for gmail draft create (#1923).
The encoding itself (RFC 2047 encoded words for non-ASCII subjects and
display names, RFC 2231 filename*= parameters, multipart/mixed
assembly and base64 transfer encoding) is mail-builder’s. This module
owns what that crate leaves to its caller:
-
Input validation. A CR or LF in a subject, display name or address would let a caller inject a header, so
Mailbox::parseandComposition::buildreject them outright rather than relying on the encoder to neutralise them. -
Reply threading. Gmail only files a draft into an existing thread when three things agree: the draft’s
threadId, itsIn-Reply-To/Referencesheaders, and itsSubject.ReplyContextderives the last two from the original message’s headers. -
Reply recipients.
ReplyContext::default_recipientsworks out who a reply goes to when the caller names nobody, as a mail client’s Reply and Reply All do (#1954). The original’s address headers are decoded withmail-parser, and every address is re-validated byMailbox::from_partsbefore it can reach a header. -
The
Message-ID.mail-builderalways writes one, and with itsgethostnamefeature off its host part islocalhost. AComposition::message_id_domainreplaces that with the account’s own domain (#1953). This is the uploaded id only: Gmail gives the stored draft an id of its own on every save (#1966). -
HTML bodies. An HTML body always goes out as
multipart/alternativebeside a plain-text part (#1955).plain_text_from_htmlderives that part when the caller has none, andinline_image_warningflags HTML that expects inline images nothing here attaches.
From is set only when the caller names one (Composition::from,
checked against the account’s send-as aliases by the caller, #1956);
otherwise Gmail fills in the authenticated account’s address.
Structs§
- Attachment
- A file attached to a composed message.
- Composition
- A message to build:
text/plain, ormultipart/alternativewhen it has an HTML body. - Mailbox
- One recipient: an address with an optional display name.
- Reply
Context - What a reply needs from the message it replies to.
Constants§
- REPLY_
HEADERS - The headers
ReplyContext::from_messagereads, for the caller’smessages.get(format=metadata)request.
Functions§
- check_
subject - Refuses a subject that would break the header.
- inline_
image_ warning - A warning when
htmlrefers to an inline image (cid:), which no command here attaches, so the image would show as broken. - message_
id_ domain - The domain part of
email, when it can serve as aMessage-ID’s right half: a dot-separated run of letters, digits and hyphens. - plain_
text_ from_ html - The plain-text alternative for an HTML body, as Markdown.
- subject_
matches_ reply - Whether
subjectkeeps a reply in the original’s thread.