Skip to main content
Archived

This project has been archived by its maintainers, and is no longer receiving any updates.

fast_mail_parser

Test PyPI version Downloads

fast_mail_parser is a Python library for .eml files parsing. The main benefit is a performance: the library is much faster than python implementations.

Based on mailparse library using pyo3.

Benchmark

 -------------------------------------------------------------------------------------------- benchmark: 2 tests -------------------------------------------------------------------------------------------
Name (time in ms)                              Min                Max               Mean            StdDev             Median               IQR            Outliers       OPS            Rounds  Iterations
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test__fast_mail_parser___parse_message      1.8136 (1.0)       1.8938 (1.0)       1.8426 (1.0)      0.0176 (1.0)       1.8465 (1.0)      0.0277 (1.0)         180;0  542.7141 (1.0)         450           1
test__mail_parser___parse_message          14.5583 (8.03)     15.8571 (8.37)     15.0264 (8.16)     0.2368 (13.49)    14.9702 (8.11)     0.2887 (10.42)         5;1   66.5495 (0.12)         32           1
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

Installation

Use the package manager pip to install fast_mail_parser.

pip install fast-mail-parser-ng

Note on the package name. The distribution is fast-mail-parser-ng, but the import path is plain fast_mail_parser — so only your requirements file changes, never your code.

The fast-mail-parser name on PyPI is a different, unmaintained upload stuck at 0.2.5 (June 2022). It predates this repository's current maintenance and we cannot publish to it; see CHANGELOG for the full story. Install fast-mail-parser-ng to get the maintained library.

Wheels target the CPython stable ABI (cp311-abi3): one wheel per platform covers every supported CPython version, including versions released after the package — a new Python no longer has to wait for a new release.

Python Support
CPython 3.11+ (including future versions) Prebuilt wheel
CPython 3.13t/3.14t (free-threaded) Builds from source; the extension currently re-enables the GIL on import (#101)
CPython ≤ 3.10 Not supported (last compatible release: 0.2.5)
PyPy Not supported

Usage

parse_email accepts the raw message as str or bytes and returns a PyMail. It raises ParseError if the payload cannot be parsed.

PyMail exposes the following attributes:

Attribute Type Description
subject str Subject header (empty string if missing).
date str Date header (empty string if missing).
text_plain list[str] All text/plain bodies.
text_html list[str] All text/html bodies.
headers dict[str, str] All message headers.
attachments list[PyAttachment] Attachments (see below).

Each PyAttachment has mimetype: str, filename: str, and content: bytes.

import sys

from fast_mail_parser import parse_email, ParseError

# parse_email accepts both str and bytes; reading in binary mode is safest.
with open('message.eml', 'rb') as f:
    message_payload = f.read()

try:
    email = parse_email(message_payload)
except ParseError as e:
    print("Failed to parse email:", e)
    sys.exit(1)

print("Subject:", email.subject)
print("Date:", email.date)

# headers is a dict[str, str].
for name, value in email.headers.items():
    print(f"{name}: {value}")

# text_plain and text_html are lists of strings (one entry per matching part).
for body in email.text_plain:
    print("Plain text body:", body)

for body in email.text_html:
    print("HTML body:", body)

# attachments is a list of PyAttachment objects.
for attachment in email.attachments:
    print("Attachment:", attachment.filename)
    print("  mimetype:", attachment.mimetype)
    print("  size:", len(attachment.content), "bytes")  # content is bytes

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

See CONTRIBUTING.md for how to build from source, run the tests, and the PR conventions (linting, CI, DCO sign-off).

Download files

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

Source Distribution

fast_mail_parser_ng-0.6.0.tar.gz (598.7 kB view details)

Uploaded Source

Built Distributions

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

fast_mail_parser_ng-0.6.0-cp311-abi3-win_amd64.whl (326.7 kB view details)

Uploaded CPython 3.11+Windows x86-64

fast_mail_parser_ng-0.6.0-cp311-abi3-win32.whl (315.4 kB view details)

Uploaded CPython 3.11+Windows x86

fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_x86_64.whl (656.1 kB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_i686.whl (680.4 kB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ i686

fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_armv7l.whl (727.8 kB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARMv7l

fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_aarch64.whl (620.9 kB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (445.4 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl (475.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ s390x

fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (476.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ppc64le

fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (451.9 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARMv7l

fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (442.5 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl (463.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.5+ i686

fast_mail_parser_ng-0.6.0-cp311-abi3-macosx_11_0_arm64.whl (417.3 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

File details

Details for the file fast_mail_parser_ng-0.6.0.tar.gz.

File metadata

  • Download URL: fast_mail_parser_ng-0.6.0.tar.gz
  • Upload date:
  • Size: 598.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for fast_mail_parser_ng-0.6.0.tar.gz
Algorithm Hash digest
SHA256 3f6ccda4ab2f20ce667da42c24f97fd59e21860ca65ed4cd6577716fe1b377aa
MD5 51bd2e629f8ea1641b8609ed577fc520
BLAKE2b-256 325d75d7a7e02d5de221e3d846c071b18a2405f868d1ddce4e89016b86695c33

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0.tar.gz:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 86472b75ebed0d5663643d28eb49927cdc85cb7bc54bbf807295328221964191
MD5 15bb8cd3696349d5f01387fdd47084f4
BLAKE2b-256 58610cd1efdd4ffe3e8cb0e5a7e1acf3f861e0ae815b9673ad31e875c458e3bc

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-win_amd64.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-win32.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-win32.whl
Algorithm Hash digest
SHA256 9eca7b4ddc450ebd1ebffb67c633c752d9c102876b08fc59d89e4f920a3036ca
MD5 9f5cdad660ccf2764943754cea7fe633
BLAKE2b-256 06d1fb4d11e42b031825a124b07a4c953978704cf950c87765a8f4d440f236f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-win32.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 5a1153da679e75cb4a19b09f75e34e4639ef153ab0bc197b7f0386dbf6559038
MD5 4f5c3ff0257c5b702b3a16785c0cdb7b
BLAKE2b-256 e733bfb8bd550700e281aaba3f490e17bc4534df4e11d80c11ef389d9d40707d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 c89e81d627d6acbad5954cb89afa7af459686030ec8ec00aa9f69abb218b2b0e
MD5 1eb2fbba90f01b2d880060af5a1acfec
BLAKE2b-256 28b7d7f62f3214386d3f2422cadc5d2ce37fbefeb0c1a51d3612d268968657f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_i686.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 14e1fea14e3a1bdfcb0376711124e7b640dc035cd5730a31a1deade353134b82
MD5 f0463fa6d37c2f5cd1d20e1a11cbfd48
BLAKE2b-256 11107a25a24cfa7c961e1e3017874270d620dd106d7b16a11c52c3121c54d520

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_armv7l.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 a1b84417e1be035369d92020e6415d25d0f69c6b9a519c04e50806dd87407d81
MD5 4d72eb1467be6f642f555658cd75d069
BLAKE2b-256 90e5faf23df07c4cb379e4ff38cf159a0c7e3b26e193bb04b6675b1d9fdb6e57

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-musllinux_1_2_aarch64.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7bf4a5e8162d4593d8f7b276cddf60043719a953433c9ec82bbbeb55b08c3e19
MD5 ac0d29a2e39b952984eb93187b826b04
BLAKE2b-256 c929128ae21a5df345b2d9ae4e47bc11ecbfbbdc9b90da39185c6389119a3f80

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 b79f2375051ee6d8cd28245281d4893b2effe6e3caa5e7cd67f4363cf0790750
MD5 331c2d359d38bc375a4ae4d6f2ade6c7
BLAKE2b-256 6bb95445c5e893c6c48d95f319663248051769cd03da757ce3458466a5820f2d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_s390x.manylinux2014_s390x.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 ca1b2df323e8aef3add2f54a51bb65d50390f145bcf8f5a7b4f80a3f912246ef
MD5 fc6c404527afca08d7d4e42460405252
BLAKE2b-256 579f96ea89267380e4b05b19f56449d8ed80fe4b947773e1ae4fa6cf52cec38f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 c0c6f5afeb0addc532991a91e62fb3854f785bf90ea1b278dd32e45e8378f1da
MD5 466dfc727dc8502041ac0d9ed49ea6ad
BLAKE2b-256 d4f9d72f102b690919d870eed102d93442050d99811a1b8b2fdbd375887cb8fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f4eddbc20e7d3c45feee1200f34fb2cbe551fd820c013ec47faa092056256d82
MD5 d472a9e339f184e2149c98c1d657c7f5
BLAKE2b-256 60d52ca95c0a6214aed575b85c3215a2b53b848f3edc9ec1c6cf92f3082de17f

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl
Algorithm Hash digest
SHA256 dd30e5deb9f2ad7848128dfff2ee89aa7dc015545e24c0b408579dc8c1bd722a
MD5 a30fd8b03fba54e5b156f9e0f285c03f
BLAKE2b-256 2407add5ab2d4ac25e5f6427ba2ec669015fa347d8a6a8704507791449078401

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-manylinux_2_5_i686.manylinux1_i686.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fast_mail_parser_ng-0.6.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fast_mail_parser_ng-0.6.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4ef1f7c3179f979df340fca2dbafb37f26a450577b51cba8984777f849bbb2f1
MD5 603ae6598799ad61b37adb4003530f77
BLAKE2b-256 a3575405b4b2202081db0fc56ef0aa7b562b9bcd21d7bbea1ade919dce3fdc6d

See more details on using hashes here.

Provenance

The following attestation bundles were made for fast_mail_parser_ng-0.6.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: publish.yml on namecheap/fast_mail_parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.6.0 This release

14 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page