Skip to main content

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

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mailparse_mailkite-0.1.0.tar.gz (22.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mailparse_mailkite-0.1.0-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file mailparse_mailkite-0.1.0.tar.gz.

File metadata

  • Download URL: mailparse_mailkite-0.1.0.tar.gz
  • Upload date:
  • Size: 22.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for mailparse_mailkite-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7ad25ef56fa8a04b8ea6d046b1eaf27036cfc955269aa5613f0f88738e3793b8
MD5 fbf331f366b3ea78b12a8d206ca672d9
BLAKE2b-256 81c80fff8206953ff2f39882d739300838af1100d40e09fa0edfb106a9a73ab9

See more details on using hashes here.

File details

Details for the file mailparse_mailkite-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mailparse_mailkite-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 76f0972b86cf9a554c7cdec57093d0faf87ad9741ed642fb23c99b396ee21944
MD5 f988892d93c1dc463ab793ed94d02ca0
BLAKE2b-256 f3f101b9d34fd0bcea1c42c5775c279753dbae2b37a7299b9f6428e588fd79ee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page