← All notes

Python email.message: the EmailMessage object model

Answer: EmailMessage is the central class of the email package object model.

Headers and payload

A message has headers plus a payload, also called the content.

A colon separates each field name from its value.

That colon belongs to neither the name nor the value.

What the class provides

Import EmailMessage from the email.message module.

The class is the base of the email object model.

It provides the core functionality for setting and querying header fields.

The same class also opens message bodies and can build structured messages.

See also

Claims

Sources

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.message: Representing an email message; CPython, email.message documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: Python Software Foundation, email.message: Representing an email message; CPython, email.message documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:1a31x24m

iinventedlight. 2026. "Python email.message: the EmailMessage object model." iinventedlight Library, iil:note:1a31x24m, version of 2026-11-26. https://iinventedlight.com/library/notes/python-email-message/. License: CC-BY-4.0.

@misc{iil_note_1a31x24m,
  author = {{iinventedlight}},
  title = {{Python email.message: the EmailMessage object model}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-26},
  url = {https://iinventedlight.com/library/notes/python-email-message/},
  note = {Permanent ID iil:note:1a31x24m. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/python-email-message.md.