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

    Module mime

    Inbound email parsing for mxRaven deliveries.

    mxRaven webhook payloads describe inbound mail as JSON, and the full message remains available as raw RFC 5322 bytes behind the payload's raw_email reference. parseEmail turns those bytes into headers, addresses, bodies, and decoded attachments; fetchAndParseRawEmail downloads, verifies, and parses them in one step:

    import { Verifier, eventType } from "@mxraven/mail/webhook";
    import { fetchAndParseRawEmail } from "@mxraven/mail/mime";

    const verifier = new Verifier({ secret });
    const event = await verifier.verifyAndDecode(request);

    if (event.type === eventType.inboundEmail) {
    const email = await fetchAndParseRawEmail(event.inboundEmail.raw_email);
    console.log(email.subject, email.attachments.length);
    }

    The parser is defensive: malformed messages yield the best available interpretation instead of an error, and unknown charsets fall back to UTF-8 and then Latin-1. It understands multipart/mixed, multipart/alternative, and multipart/related, decodes base64 and quoted-printable transfer encodings, decodes RFC 2047 encoded words, and reassembles RFC 2231 parameters. message/rfc822 parts are surfaced as attachments rather than parsed recursively. Only unbounded input — very deep nesting or thousands of parts — is rejected.

    ParsedAddress
    ParsedAttachment
    ParsedEmail
    ParsedHeader
    fetchAndParseRawEmail
    parseEmail