mailio_mime (mailio v0.2.0)

MIME tree parser (pure, total).

Parses raw RFC 5322 bytes into a tree of parts. A leaf part carries a decoded body; a multipart or message/rfc822 part carries parts. The parser never throws: structural problems (missing boundary, truncation, excessive nesting) are recorded in each part's defects list and parsing continues best-effort, matching the "never crash on real-world mail" policy.

Summary

Functions

All leaf parts (those with a decoded body), in document order.

Parse raw message bytes into a part tree.

Depth-first fold over every part (including container parts).

Types

part/0

-type part() ::
          #{type := binary(),
            subtype := binary(),
            params := map(),
            encoding := binary(),
            disposition := binary() | undefined,
            disposition_params := map(),
            charset := binary() | undefined,
            filename := binary() | undefined,
            content_id := binary() | undefined,
            headers := mailio_rfc5322:header_list(),
            defects := [term()],
            body => binary(),
            parts => [part()]}.

Functions

body(Part)

-spec body(part()) -> binary() | undefined.

charset(_)

-spec charset(part()) -> binary() | undefined.

content_type(_)

-spec content_type(part()) -> binary().

defects(_)

-spec defects(part()) -> [term()].

filename(_)

-spec filename(part()) -> binary() | undefined.

header(Name, _)

-spec header(binary(), part()) -> binary() | undefined.

is_attachment(_)

-spec is_attachment(part()) -> boolean().

is_multipart(_)

-spec is_multipart(part()) -> boolean().

leaves(Part)

-spec leaves(part()) -> [part()].

All leaf parts (those with a decoded body), in document order.

parse(Raw)

-spec parse(binary()) -> part().

Parse raw message bytes into a part tree.

parts(Part)

-spec parts(part()) -> [part()].

subtype(_)

-spec subtype(part()) -> binary().

type(_)

-spec type(part()) -> binary().

walk(Fun, Acc)

-spec walk(fun((part(), Acc) -> Acc), Acc) -> fun((part()) -> Acc) when Acc :: term().

Depth-first fold over every part (including container parts).