How mail-parser represents message content
mainUnlike many parsers that return deeply nested MIME trees, mail-parser follows RFC 8621, Section 4.1.4 to provide a flattened, human-friendly view.
Instead of navigating a complex tree of MIME parts, you can directly access:
- Text body parts: Via
.body_text(index). - HTML body parts: Via
.body_html(index). - Attachments: Via
.attachment(index).
If a message contains an alternative part but is missing one of the formats (e.g., it has HTML but no plain text), the library automatically performs the conversion for you so that .body_text() and .body_html() remain usable.