{ "module": "mail_intake.parsers.headers", "content": { "path": "mail_intake.parsers.headers", "docstring": "Message header parsing utilities for Mail Intake.\n\nThis module provides helper functions for normalizing and extracting\nuseful information from provider-native message headers.\n\nThe functions here are intentionally simple and tolerant of malformed\nor incomplete header data.", "objects": { "Dict": { "name": "Dict", "kind": "alias", "path": "mail_intake.parsers.headers.Dict", "signature": "", "docstring": null }, "List": { "name": "List", "kind": "alias", "path": "mail_intake.parsers.headers.List", "signature": "", "docstring": null }, "Tuple": { "name": "Tuple", "kind": "alias", "path": "mail_intake.parsers.headers.Tuple", "signature": "", "docstring": null }, "Optional": { "name": "Optional", "kind": "alias", "path": "mail_intake.parsers.headers.Optional", "signature": "", "docstring": null }, "parse_headers": { "name": "parse_headers", "kind": "function", "path": "mail_intake.parsers.headers.parse_headers", "signature": "", "docstring": "Convert a list of Gmail-style headers into a normalized dict.\n\nProvider payloads (such as Gmail) typically represent headers as a list\nof name/value mappings. This function normalizes them into a\ncase-insensitive dictionary keyed by lowercase header names.\n\nArgs:\n raw_headers: List of header dictionaries, each containing\n ``name`` and ``value`` keys.\n\nReturns:\n Dictionary mapping lowercase header names to stripped values.\n\nExample:\n Input:\n [\n {\"name\": \"From\", \"value\": \"John Doe \"},\n {\"name\": \"Subject\", \"value\": \"Re: Interview Update\"},\n ]\n\n Output:\n {\n \"from\": \"John Doe \",\n \"subject\": \"Re: Interview Update\",\n }" }, "extract_sender": { "name": "extract_sender", "kind": "function", "path": "mail_intake.parsers.headers.extract_sender", "signature": "", "docstring": "Extract sender email and optional display name from headers.\n\nThis function parses the ``From`` header and attempts to extract:\n- Sender email address\n- Optional human-readable display name\n\nArgs:\n headers: Normalized header dictionary as returned by\n :func:`parse_headers`.\n\nReturns:\n A tuple ``(email, name)`` where:\n - ``email`` is the sender email address\n - ``name`` is the display name, or ``None`` if unavailable\n\nExamples:\n ``\"John Doe \"`` → ``(\"john@example.com\", \"John Doe\")``\n ``\"john@example.com\"`` → ``(\"john@example.com\", None)``" } } } }