pub fn build_message(email: &OutgoingEmail) -> Result<BuiltMessage, Error>Expand description
Builds an RFC 5322 message from an OutgoingEmail.
Returns raw bytes, the list of all envelope recipients (to + cc + bcc)
for SMTP RCPT TO, and the generated Message-ID.
Text MIME parts always use 7-bit safe encoding: pure ASCII with
conforming lines gets Content-Transfer-Encoding: 7bit (RFC 2045
Section 2.7); anything else uses quoted-printable (RFC 2045
Section 6.7). This guarantees the built bytes can be sent to any SMTP
server — with or without 8BITMIME — and stored via IMAP APPEND
without re-encoding.
BCC addresses are included in BuiltMessage::envelope_recipients but
are not present in the message headers (RFC 5322 Section 3.6.3).
§Errors
Returns Error::InvalidAddress for syntactically invalid email addresses,
Error::HeaderLineTooLong for unfoldable header tokens,
Error::ReservedHeaderName for collisions with builder-managed headers,
Error::InvalidAttachment for MIME constraint violations,
Error::InvalidTraceHeader for malformed trace fields, or
Error::InvalidResentHeader for malformed resent fields.
§References
- RFC 5322 (message format)
- RFC 2046 (MIME multipart)
- RFC 2045 (Content-Transfer-Encoding)