mailbits
Assorted e-mail utility functions
What it is and what it does
mailbits is a small utility library that wraps Python's standard email module to make working with Message, EmailMessage, Address, and Group objects simpler and more inspectable. It provides functions to parse Content-Type headers into structured objects, convert email messages into plain Python dicts for easier inspection and comparison, extract recipient addresses, and convert between the older Message class and newer EmailMessage format.
The main use case is when you need to examine or manipulate email messages programmatically but find the standard library's API cumbersome—for instance, when comparing two messages for equality, pretty-printing message structure, or extracting specific address fields. The dict conversion handles nested multipart messages, decodes encoded text and bytes, and provides special representations for headers like From, To, and Content-Type.
Use it for:
- Convert email Message objects to dicts for easier testing and comparison in unit tests
- Parse and inspect Content-Type headers to extract media type and parameters
- Extract and format recipient email addresses from EmailMessage objects
- Convert legacy Message instances to the newer EmailMessage format
- Pretty-print or log the structure of a multipart email for debugging
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Provides utilities for parsing, converting, and inspecting email Message and EmailMessage objects from Python's standard library, including Content-Type parsing, message-to-dict conversion, and address extraction.
Yes. mailbits is actively maintained, has no known vulnerabilities, low install friction, and a permissive MIT license. It solves a real friction point in the standard library's email API. Install it if you work with email messages and need cleaner introspection or conversion utilities.
Install
mailbits on PyPI
pip
pip install mailbitsuv
uv add mailbitspoetry
poetry add mailbitsInstalling mailbits
Before you install
Low install friction with a single lightweight dependency. Actively maintained with recent commits; requires Python 3.10 or higher.
License in practice
MIT license permits free use, modification, and distribution with minimal restrictions, suitable for both open-source and commercial projects.
Quickstart
pip install mailbits
from mailbits import ContentType, email2dict
ct = ContentType.parse("text/plain; charset=utf-8")
print(ct.maintype, ct.subtype)
msg_dict = email2dict(msg)
Requires Python 3.10 or higher
Verify before relying
- Whether the package handles all RFC 5322 edge cases or has known parsing limitations
- Performance characteristics when processing large or deeply nested multipart messages
- Whether attrs is required at runtime or only for development
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 1 — attrs |
| Maintenance | actively maintained — 258 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 334,729/month — #7,484 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: mailbits-0.2.3-py3-none-any.whl
Keywords: EmailMessage, content type, e-mail, e-mail address, e-mail comparison, e-mail inspection, email, recipients
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
mail-parserParses raw email messages into structured…
permissive · top 5,000 on PyPI
email-validatorValidates email address syntax and optionally…
permissive · top 1,000 on PyPI
imap-toolsA high-level Python library for IMAP email…
permissive · top 15,000 on PyPI
quotequailIdentifies and separates quoted text from…
permissive · top 15,000 on PyPI
flufl.bounceDetects and extracts original bouncing email…
permissive · top 15,000 on PyPI
pyapPyap detects and parses postal addresses from…
permissive · top 15,000 on PyPI
pyap2Pyap2 detects and parses postal addresses from…
permissive · top 15,000 on PyPI
postmarkerPostmarker is a Python client library for the…
permissive · top 5,000 on PyPI
iptoolsProvides utilities for parsing, validating, and…
permissive · top 15,000 on PyPI