skillfed

mailbits

Assorted e-mail utility functions

mailbits v0.2.3 334.7K downloads/30d#7,484 on PyPI3
Permissive license MIT Active released

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 mailbits

uv

uv add mailbits

poetry

poetry add mailbits

Installing 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

Intended Audience :: DevelopersProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: Implementation :: CPythonProgramming Language :: Python :: Implementation :: PyPyTopic :: Communications :: EmailTopic :: UtilitiesTyping :: Typed

Tags

email message parsing utilitiesconvert email message to dictparse content-type headersextract email addressesemail inspection toolsmessage structure analysisemailmessage utilities
email-utilitiesmessage-parsing

More Utilities packages