Streaming, memory-efficient MIME email parser — the Python port of @mailkite/mail-parse.
Same parsed Message shape, and a failure-signature primitive whose hashes match the TypeScript package byte-for-byte.
Docs · Libraries · Node / TypeScript · mailkite.dev
Maintained in the MailKite monorepo; this is the public home for the Python port. The TypeScript package (
mail-parse) is the reference implementation.
- Cross-language SSOT —
compute_signature()produces the same failure-signature hash as the TypeScript package for the same failure (conformance-tested against hashes captured from TS). - Same
Messageshape —parse()returns the same structured fields, so payloads are consistent across your stack. - Tolerant — malformed input never raises.
pip install mailparse-mailkitefrom mailparse import parse, compute_signature
msg = parse(raw_bytes)
msg.from_ # Address(address=..., name=...)
msg.subject
msg.text; msg.html
msg.attachments # [Attachment(filename, mimeType, content: bytes, size, ...)]
# Deterministic, PII-free fingerprint of a parse failure — identical hash to the TS package.
sig = compute_signature({"scope": "part", "diagnosticCodes": ["UNKNOWN_CHARSET"],
"contentType": "text/plain"})
sig["hash"]The failure-signature primitive is fully ported and cross-language conformance-tested. parse() is
built on the stdlib email package (the documented ContentManager precedent) — the buffered path.
Porting the streaming splitter + middleware registry to Python is in progress; the
TypeScript package is the reference.
python3 -m unittest discover -s tests| Library | Repo | Distribution |
|---|---|---|
| mail-parse (Node / TypeScript) | mail-parse |
npm |
| mail-parse (Python) (this repo) | mail-parse-py |
PyPI |
| MailKite for Python | mailkite-python |
PyPI |
| MailKite for Node.js | mailkite-node |
npm |
Full list: https://mailkite.dev/docs/libraries.
- 📚 Documentation: https://mailkite.dev/docs
- 🟦 TypeScript reference: https://github.com/mailkite/mail-parse
- 🌐 Website: https://mailkite.dev
MIT licensed. © MailKite.