Headers
mail_intake.parsers.headers
Summary
Message header parsing utilities for Mail Intake.
This module provides helper functions for normalizing and extracting useful information from provider-native message headers.
The functions here are intentionally simple and tolerant of malformed or incomplete header data.
Functions
extract_sender
Extract sender email and optional display name from headers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
headers |
Dict[str, str]
|
Normalized header dictionary as returned by |
required |
Returns:
| Type | Description |
|---|---|
Tuple[str, Optional[str]]
|
Tuple[str, Optional[str]]:
A tuple |
Notes
Responsibilities:
1 2 | |
Example
Typical values:
"John Doe <john@example.com>"->("john@example.com", "John Doe")"john@example.com"->("john@example.com", None)
parse_headers
Convert a list of Gmail-style headers into a normalized dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
raw_headers |
List[Dict[str, str]]
|
List of header dictionaries, each containing |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Dict[str, str]: Dictionary mapping lowercase header names to stripped values. |
Notes
Guarantees:
1 2 3 4 | |