Skip to content

mailkite/mail-parse-py

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MailKite

MailKite mail-parse (Python)

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

MIT · Python 3.8+

Maintained in the MailKite monorepo; this is the public home for the Python port. The TypeScript package (mail-parse) is the reference implementation.

Why

  • Cross-language SSOTcompute_signature() produces the same failure-signature hash as the TypeScript package for the same failure (conformance-tested against hashes captured from TS).
  • Same Message shapeparse() returns the same structured fields, so payloads are consistent across your stack.
  • Tolerant — malformed input never raises.

Install

pip install mailparse-mailkite

Quickstart

from 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"]

Status

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.

Develop

python3 -m unittest discover -s tests

All MailKite libraries

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.

Docs & links

MIT licensed. © MailKite.

About

Python port of @mailkite/mail-parse — MIME parser + cross-language failure-signature primitive.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages