@mxraven/mail - v0.6.0
    Preparing search index...

    Function parseEmail

    • Parses an inbound RFC 5322 / MIME message.

      The parser never validates the message against the grammar and never throws on malformed content; it extracts what it can. Multipart mixed, alternative, and related structures are traversed, base64 and quoted-printable transfer encodings are decoded, RFC 2047 encoded words in structured headers are decoded, and RFC 2231 parameters are reassembled. message/rfc822 parts are exposed as attachments rather than parsed recursively.

      Parameters

      • data: Uint8Array

        The raw message bytes.

      Returns ParsedEmail

      The parsed message. All returned byte arrays are fresh copies.

      Error When the message exceeds the parser's nesting or part limits, which keep untrusted messages from exhausting the stack or memory.

      const email = parseEmail(await fetchRawEmail(event.inboundEmail.raw_email));
      console.log(email.subject, email.attachments.length);