---
source: https://iinventedlight.com/library/notes/python-email-parser.md
title: "Python email.parser: turn serialized messages into EmailMessage trees"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "PSF License Version 2 (Python Software Foundation); PSF License Version 2 (CPython); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, email.parser: Parsing email messages; CPython, email.parser documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-26
status: published
approved_by: "Cole Withington, 2026-11-27 14:30 PT: \"Yes, publish all of that now\""
checked_on: 2026-11-26
as_of: 2026-11-26
confidence: medium
untested: "Not reproduced (2026-11-26). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: python-email-parser"
tags: [python, email, parser, mime, feedparser]
client: Librarian
sources:
  - id: S1
    title: "email.parser: Parsing email messages"
    publisher: Python Software Foundation
    url: https://docs.python.org/3/library/email.parser.html
    accessed: 2026-11-26
    license: "PSF License Version 2"
  - id: S2
    title: "email.parser documentation (source)"
    publisher: CPython
    url: https://raw.githubusercontent.com/python/cpython/main/Doc/library/email.parser.rst
    accessed: 2026-11-26
    license: "PSF License Version 2"
---
# Python email.parser: turn serialized messages into EmailMessage trees
**Answer:** email.parser turns a serialized email message into an EmailMessage object tree.

## What the parser returns

The email package provides a standard parser that understands most email document structures, including MIME.

You can pass it a bytes object, a string, or a file object.

It returns the root EmailMessage instance of the object structure.

For MIME messages, that root object reports that it is multipart, and subparts are reached through payload methods.

## Parser versus FeedParser

Two interfaces are available: the Parser API and the incremental FeedParser API.

Parser is most useful when the entire message is already in memory or in a file.

FeedParser fits a stream that might block waiting for more input, such as a socket.

The incremental parser only returns the root object when you close it.

Header-only parsers can be much faster, because they do not attempt to parse the message body.

## See also

- [python-email](https://iinventedlight.com/library/notes/python-email/)
- [python-email-message](https://iinventedlight.com/library/notes/python-email-message/)
- [python-mailbox](https://iinventedlight.com/library/notes/python-mailbox/)

## Claims

- id: C1
  claim: The email package provides a standard parser that understands most email document structures.
  source: S1
  evidence: "provides a standard parser that understands most email document structures"

- id: C2
  claim: You can pass the parser a bytes, string, or file object.
  source: S1
  evidence: "You can pass the parser a bytes, string or file object"

- id: C3
  claim: The semantics and results of the two parser APIs are identical.
  source: S2
  evidence: "The semantics and results of the two parser APIs are identical"

- id: C4
  claim: Header-only parsers can be much faster because they do not attempt to parse the message body.
  source: S2
  evidence: "they do not attempt to parse the message body"

## Sources

- [S1] email.parser: Parsing email messages. Python Software Foundation. https://docs.python.org/3/library/email.parser.html . License: PSF License Version 2. Accessed 2026-11-26.

- [S2] email.parser documentation (source). CPython. https://raw.githubusercontent.com/python/cpython/main/Doc/library/email.parser.rst . License: PSF License Version 2. Accessed 2026-11-26.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, email.parser: Parsing email messages; CPython, email.parser documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
