Skip to main content

parse_email

Function parse_email 

Source
pub fn parse_email(raw: &[u8]) -> Result<ParsedEmail, Error>
Expand description

Parses raw email message bytes into a structured representation.

Handles partial messages (headers + truncated body) gracefully, extracting whatever content is available. Returns Error::EmptyInput for empty input. Malformed but still usable messages that omit the required From header are accepted with an empty from list.

§References

  • RFC 5322 Sections 2.1–2.3 (header/body separation, line length)
  • RFC 5322 Sections 3.3–3.6 (date-time, address, field definitions)
  • RFC 2045 Section 6 (Content-Transfer-Encoding decoding)
  • RFC 2046 Sections 5.1–5.2 (multipart boundary parsing)
  • RFC 2047 Sections 3–4 (encoded-word decoding in headers)
  • RFC 2183 Section 2 (Content-Disposition parsing)
  • RFC 2231 Sections 3–4 (parameter continuations, charset/language)
  • RFC 6532 Section 3 (internationalized header fields)