Skip to main content

Very fast Python library for .eml files parsing.

Project description

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

============================= test session starts ==============================
platform linux -- Python 3.8.5, pytest-6.0.1
benchmark: 3.2.3 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)

Name (time in ms)                              Min                Max               Mean            StdDev             Median               IQR            Outliers       OPS            Rounds  Iterations
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test__fast_mail_parser___parse_message      1.7381 (1.0)      10.2716 (1.0)       2.0991 (1.0)      0.4700 (1.0)       2.0442 (1.0)      0.2377 (1.0)         13;17  476.3975 (1.0)         403           1
test__mail_parser___parse_message          15.1113 (8.69)     18.5801 (1.81)     16.0706 (7.66)     0.8949 (1.90)     15.7256 (7.69)     0.7293 (3.07)          2;1   62.2253 (0.13)         12           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

Usage

import sys
from fast_mail_parser import parse_email, ParseError

with open('message.eml', 'r') 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(email.subject)
print(email.date)
print(email.text_plain)
print(email.text_html)
print(email.headers)

for attachment in email.attachments:
    print(attachment.mimetype)
    print(attachment.content)
    print(attachment.filename)

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.

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

fast_mail_parser-0.2.1.tar.gz (413.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-0.2.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl (377.6 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.5+ x86-64

fast_mail_parser-0.2.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl (377.6 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.5+ x86-64

fast_mail_parser-0.2.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl (377.9 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.5+ x86-64

fast_mail_parser-0.2.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (377.9 kB view details)

Uploaded CPython 3.7mmanylinux: glibc 2.5+ x86-64

fast_mail_parser-0.2.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (377.7 kB view details)

Uploaded CPython 3.6mmanylinux: glibc 2.5+ x86-64

File details

Details for the file fast_mail_parser-0.2.1.tar.gz.

File metadata

  • Download URL: fast_mail_parser-0.2.1.tar.gz
  • Upload date:
  • Size: 413.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.6.3 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.0 CPython/3.9.6

File hashes

Hashes for fast_mail_parser-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b0887d1ad5572bd9b990aa402dd095e9b70a4c60ef0041d05d517ee1429266cd
MD5 a76d7529ad557ad9d527356aa191aa11
BLAKE2b-256 f8e3920fffc0dcea5cf4c43445688275c57edb7eeaf679900ff3182e4ab36f64

See more details on using hashes here.

File details

Details for the file fast_mail_parser-0.2.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for fast_mail_parser-0.2.1-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 2d24168d588e5264d98b5657f0be4d88e645885b334ce4f1f08edab571b142a6
MD5 989152bc53e8483e346c68600092ab41
BLAKE2b-256 b86de9f53abff8d728d50e8b621f3d7493dc1b5acaf56e2112bec3fc3114f686

See more details on using hashes here.

File details

Details for the file fast_mail_parser-0.2.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for fast_mail_parser-0.2.1-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 8e2b05568ee5391f87f6d909d92e70f83a4d8344196968605abc2a1c8398ec24
MD5 63332e454df6c4a3041f7a0ca8b675cc
BLAKE2b-256 f3349da94ea1dce0951fa6692db7ff6b3e60f3ea3b1e10364d9f667483e205e5

See more details on using hashes here.

File details

Details for the file fast_mail_parser-0.2.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for fast_mail_parser-0.2.1-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 53bfd759dceb9314185c56ab25a298614c167407dc73c9678ff634e203f114f9
MD5 f8c56597b1d2d982108b3f3c0ee5f7e9
BLAKE2b-256 0b80758e94cbf62637d2933b94ab78ff3d65ad5bd59a5cc40ae312f72aab1a0e

See more details on using hashes here.

File details

Details for the file fast_mail_parser-0.2.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for fast_mail_parser-0.2.1-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3840ece4587203eb31d7df43d72074f3707251c7feebe9037289da9a2450121a
MD5 44fe6b2d0ebfc3b519215e425f805455
BLAKE2b-256 bb91411ca8756e47f7dab3a407d082e5e1d2f183771be957df0e2945fc251576

See more details on using hashes here.

File details

Details for the file fast_mail_parser-0.2.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for fast_mail_parser-0.2.1-cp36-cp36m-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 92373be3e4f851a6ae04be8d865f9a6fec4f85aa6e346cd13d589d60efb9905c
MD5 99bf80b7888b63968fb483d61c2c5ae1
BLAKE2b-256 b1b8e2add488fd524f6cb0265c76abc6451c0f095eaeb5fb320e2b8c97bc76fa

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