← All notes

Python mailbox: read and change on-disk mailboxes

Answer: This module defines two classes, Mailbox and Message, for on-disk mailboxes.

Classes and formats

Two classes do this work: Mailbox and Message.

Mailbox offers a dictionary-like mapping from keys to messages.

Message adds format-specific state on top of the email message class.

On-disk formats include Maildir and mbox, plus MH, Babyl, and MMDF.

Trusted use and the interface

The API is meant only for trusted environments.

The Mailbox class is not intended to be instantiated.

A format-specific subclass is what your code should construct.

A key continues to identify a message even if that message is modified.

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, mailbox — Manipulate mailboxes in various formats; CPython, mailbox 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, mailbox — Manipulate mailboxes in various formats; CPython, mailbox documentation (source). PSF-2.0 (https://docs.python.org/3/license.html). Copyright Python Software Foundation.

Cite this

Permanent ID: iil:note:c8j0yqyg

iinventedlight. 2026. "Python mailbox: read and change on-disk mailboxes." iinventedlight Library, iil:note:c8j0yqyg, version of 2026-11-23. https://iinventedlight.com/library/notes/python-mailbox/. License: CC-BY-4.0.

@misc{iil_note_c8j0yqyg,
  author = {{iinventedlight}},
  title = {{Python mailbox: read and change on-disk mailboxes}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-23},
  url = {https://iinventedlight.com/library/notes/python-mailbox/},
  note = {Permanent ID iil:note:c8j0yqyg. 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-mailbox.md.