Registry / serialization / eml-parser

eml-parser

JSON →
library3.0.1pypypi✓ verified 89d ago

eml-parser is a Python library designed for parsing EML (Email Message) files, extracting headers, body content, attachments, and other email components into a structured dictionary. It is currently at version 3.0.0 and maintains an active development pace with releases for new features, bug fixes, and Python version compatibility.

pip install eml-parser
INSTALL
IMPORT
SIG · EML-PARSER
E
eml-parser
serializationpythonv3.0.1
Install
2.2s avg
Import
896ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.950s · 20.1MB
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 2.2s · import 0.841s · 21MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

EmlParser
✓ from eml_parser import EmlParser

This quickstart demonstrates how to initialize the EmlParser and parse EML content from a string. The parsed data is returned as a dictionary, allowing easy access to headers, body, and other elements. An example of how to parse from a file is also included as a comment.

from eml_parser import EmlParser eml_content = """ From: sender@example.com To: receiver@example.com Subject: Test Email Date: Thu, 1 Jan 2023 12:00:00 +0000 Content-Type: text/plain; charset="utf-8" This is a sample email body. """ # Initialize the parser parser = EmlParser() # Parse the EML content from a string parsed_eml = parser.parse_from_string(eml_content) # Print some extracted data print(f"From: {parsed_eml['header']['from']}") print(f"Subject: {parsed_eml['header']['subject']}") if parsed_eml['body']: print(f"Body content: {parsed_eml['body'][0]['content']}") # Example for parsing from a file # with open('path/to/your.eml', 'rb') as f: # file_content = f.read() # parsed_eml_file = parser.parse_from_string(file_content.decode('utf-8', errors='ignore')) # print(f"File Subject: {parsed_eml_file['header']['subject']}")
Debug
Known issues
breakingVersion 3.0.0 and newer require Python 3.10 or higher. Running on older Python versions will result in `SyntaxError` or `ModuleNotFoundError` for incompatible type hints.
fix
Upgrade your Python environment to 3.10 or newer, or pin `eml-parser<3.0.0` if you must use an older Python version.
affects: >=3.0.0
breakingThe typing syntax was upgraded for Python 3.10+ in v3.0.0. If you have custom code extending or directly interacting with internal types, it might require adjustments.
fix
Review your code for compatibility with Python 3.10+ typing syntax and update accordingly. Most basic usage should be unaffected.
affects: >=3.0.0
gotchaVersion 2.0.0 introduced support for custom parsing policies. If your application relies on specific parsing behaviors that might have been influenced by new policy options, review if a custom policy is needed.
fix
Consult the official documentation for custom policy options and implement one if the default behavior no longer meets your requirements.
affects: >=2.0.0
gotchaStarting from v1.17.0, new validation options were added for URLs, email addresses, and IP addresses (e.g., Public Suffix List, `ip_force_routable`, `domain_force_tld`). This might cause previously parsed 'valid' items to be filtered out.
fix
Review the parsing options and explicitly configure `EmlParser` settings if you need to disable or fine-tune these new validation behaviors to match prior results.
affects: >=1.17.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'eml_parser'
The `eml-parser` library is not installed in your current Python environment, or the environment is not active.
fix
Run `pip install eml-parser` to install the package.
SyntaxError: invalid syntax (some_file.py, line X)
You are attempting to run `eml-parser` version 3.0.0 or higher on a Python version older than 3.10. The library uses modern Python 3.10+ typing syntax.
fix
Upgrade your Python interpreter to version 3.10 or newer. Alternatively, if you cannot upgrade Python, install an older compatible version of the library: `pip install eml-parser<3.0.0`.
KeyError: 'subject'
The expected key (e.g., 'subject', 'from') does not exist in the parsed EML header or body dictionary for the specific email being processed. This often happens with malformed or unusual EML files.
fix
Always check for the existence of keys before accessing them, especially when dealing with potentially non-standard EML files. Use `.get()` with a default value, or wrap access in a `try-except KeyError` block, or use `if key in dict:`.
Upgrade
Version history
3.0.1latest on PyPI · released May 5, 2026
Audit
Dependencies
pythonrequiredRequires Python 3.10 or newer due to modern typing syntax and EOL of older Python versions.
Agent activity
34 hits · last 30 days
node
30
OpenAI (training)
2
Amazon
1
Resources
eml-parser — pip install eml-parser · libregistry