Skip to content

Body

mail_intake.parsers.body

Message body extraction utilities for Mail Intake.

This module contains helper functions for extracting a best-effort plain-text body from provider-native message payloads.

The logic is intentionally tolerant of malformed or partial data and prefers human-readable text over fidelity to original formatting.

extract_body

extract_body(payload: Dict[str, Any]) -> str

Extract the best-effort message body from a Gmail payload.

Priority: 1. text/plain 2. text/html (stripped to text) 3. Single-part body 4. empty string (if nothing usable found)

Parameters:

Name Type Description Default
payload Dict[str, Any]

Provider-native message payload dictionary.

required

Returns:

Type Description
str

Extracted plain-text message body.