skillfed

mail-parser

A tool that parses emails by enhancing the Python standard library, extracting all details into a comprehensive object.

mail-parser v4.6.2 3.2M downloads/30d#2,687 on PyPI
Permissive license Apache-2.0 Active released

What it is and what it does

mail-parser is a production-grade email parsing library that transforms raw email messages into richly structured Python objects. It goes beyond Python's standard email module by extracting every component—headers, plain-text and HTML bodies, attachments with full metadata, routing chains from Received headers, and RFC defects—into a unified object model. Every parsed element is accessible in three formats: native Python objects for direct use, raw strings preserving original formatting, and JSON for integration with external systems.

The library is built for security and forensics use cases, with particular strength in detecting malformed structures, RFC violations, and hidden content that could indicate malicious intent. It natively handles both standard .eml files and Microsoft Outlook .msg files (via the optional extract-msg backend). With no runtime dependencies and support for Python 3.9 through 3.14, it is designed to integrate into production email security pipelines, threat analysis platforms, and compliance workflows.

Use it for:

  • Security analysis: detect malformed email structures, RFC violations, and anomalies that may indicate phishing or malware.
  • Email forensics: extract complete routing chains, timestamps, and metadata for incident investigation and evidence preservation.
  • Outlook integration: parse .msg files from Microsoft Outlook alongside standard .eml messages in unified workflows.
  • Compliance auditing: extract and validate email headers and routing for regulatory requirements and audit trails.
  • Threat intelligence: feed parsed email components into automated detection systems for spam, phishing, and malware analysis.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Parses raw email messages into structured Python objects with RFC compliance, extracting headers, bodies, attachments, routing information, and defects for security analysis and forensics.

Yes. mail-parser is actively maintained, has no runtime dependencies, supports current Python versions, carries a permissive Apache-2.0 license, and has no known vulnerabilities. It is purpose-built for email security and forensics with proven production use. Install it if you need reliable, RFC-compliant email parsing with security-focused defect detection; the optional Outlook support makes it versatile for mixed email ecosystems.

Install

mail-parser on PyPI

pip

pip install mail-parser

uv

uv add mail-parser

poetry

poetry add mail-parser

Installing mail-parser

Before you install

Low friction installation with no runtime dependencies. Actively maintained with a release 2 days ago and support for current Python versions (3.9–3.14). Optional Outlook support via the `[outlook]` extra.

License in practice

Apache-2.0 permissive license allows free use, modification, and distribution with minimal restrictions, suitable for both open-source and commercial projects.

Quickstart

pip install mail-parser

from mail_parser import parse_from_file
mail = parse_from_file('message.eml')
print(mail.from_, mail.to, mail.subject)

Requires Python 3.9 or later. Optional: install mail-parser[outlook] for native .msg file support via extract-msg.

Verify before relying

  • Exact performance characteristics (parsing speed, memory usage) for large-scale deployments or very large attachments.
  • Completeness of RFC compliance coverage—which specific RFCs are fully supported versus partially.
  • Availability and quality of API documentation beyond the description excerpt.

Package facts

License Apache-2.0 (permissive)
Python support supports the current Python release (<3.15,>=3.9)
Install friction low — pure-Python wheel
Runtime dependencies none
Maintenance actively maintained — 2 days since the last release
First released
Downloads 3,238,692/month — #2,687 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: mail_parser-4.6.2-py3-none-any.whl

Keywords: email, forensics, mail, malware, parser, phishing, security, spam, threat detection

Natural Language :: EnglishOperating System :: MacOSOperating System :: Microsoft :: WindowsOperating System :: UnixProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.9

Tags

email parsing libraryRFC-compliant email parseremail security analysisextract email headers and attachmentsemail forensics toolparse eml and msg filesemail threat detection
email-securityforensicsrfc-compliant

More Security packages