Skip to content

# Body

## `` mail_intake.parsers.body

### Summary

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.

### Classes

### Functions

#### `` extract_body

    1

    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:

Name | Type | Description
--- | --- | ---
`str` | `str` | Extracted plain-text message body.