Skip to main content

render_rfc822

Function render_rfc822 

Source
pub fn render_rfc822(message: &Message) -> Result<Vec<u8>, MessageRenderError>
Expand description

Render a structured Message as RFC822/MIME bytes.

§Encoding choices

Non-ASCII Body::Text and Body::Html values are always rendered with Content-Transfer-Encoding: base64. ASCII text bodies whose physical lines would exceed RFC 5322’s 998-octet hard limit are rendered with Content-Transfer-Encoding: quoted-printable. A message parsed from quoted-printable bytes through parse_rfc822 and rendered back through this function will therefore round-trip with a different Content-Transfer-Encoding. Callers that need quoted-printable for near-ASCII bodies can construct a MimePart::Leaf with an explicit content_transfer_encoding and use Body::Mime.

§Errors

Returns MessageRenderError when headers or MIME parts cannot be rendered according to this crate’s RFC822 constraints.