Introducing The Sweep: OX’s New Live Security Research Series
Register Now
Breaking: The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Read the Report
Are you exposed? Connect your apps in minutes.
Scan your apps free

mail-parser

Latest version: v4.14.0

Overview

Last scanned
4 Dec 2026
Published
4 Dec 2026
PyPI package Publisher: fmantuano
460 Stars
111 Forks
6 Versions
5.7M Downloads
Python Repo language

Scan summary

mail-parser was last scanned on 4 Dec 2026 at version 4.14.0. Risk score 0 of 100. No malicious behavior was detected.

  • Releases: 6 versions; the latest 2 were published within 4 days (1–4 Dec 2026).
  • Findings: No rules fired in version 4.14.0.
  • Downloads: 5,671,450 downloads.

Versions

6 versions published
Versions and the rules that fired in each
VersionPublishedStatus
4.14.0 LATEST 4 Dec 2026 No rules fired
4.13.0 1 Dec 2026 No rules fired
4.12.0 26 Nov 2026 No rules fired
4.11.0 15 Nov 2026 Not shown
4.10.0 30 Oct 2026 Not shown

No rules fired in 4.14.0

Findings

Findings for v4.14.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.

The score describes 4.14.0; other versions have their own rules, not their own score.

Known vulnerabilities

6 CVEs · last 16 Nov 2026

0 CRITICAL 2 HIGH 4 MEDIUM 0 LOW

Versions

  • ≥ 4.6.3
  • ≥ 4.6.2, < 4.6.3 2 MEDIUM
  • ≥ 4.6.1, < 4.6.2 1 HIGH 3 MEDIUM
  • ≥ 4.6.0, < 4.6.1 2 HIGH 3 MEDIUM
  • ≥ 4.2.0, < 4.6.0 2 HIGH 3 MEDIUM
  • ≥ 3.8.0, < 4.2.0 1 HIGH 3 MEDIUM
  • ≥ 3.7.0, < 3.8.0 1 HIGH 2 MEDIUM
  • < 3.7.0 1 HIGH 1 MEDIUM

Vulnerabilities

  • CVE-2026-129301 Medium 16 Nov 2026 mail-parser: mail-parser: Security inspection bypass via malformed email attachment Fixed in 4.6.3
  • CVE-2026-129300 Medium 16 Nov 2026 mail-parser: mail-parser: Denial of Service via crafted Received header date Fixed in 4.6.3
  • CVE-2026-129299 Medium 16 Nov 2026 mail-parser: mail-parser: Security inspection bypass via crafted email messages Fixed in 4.6.2
  • CVE-2026-129297 High 16 Nov 2026 mail-parser: Sender IP address spoofing in get_server_ipaddress() Fixed in 4.6.2
  • CVE-2026-129296 Medium 16 Nov 2026 mail-parser: mail-parser: Arbitrary file overwrite via directory traversal in attachment extraction Fixed in 4.6.0
  • CVE-2026-129295 High 16 Nov 2026 mail-parser: mail-parser: Denial of Service via regular expression backtracking in email headers Fixed in 4.6.1

README

The publisher’s own README, as collected from the registry.

PyPI - Version PyPI - Downloads Sponsor

SpamScope

mail-parser

Project website: spamscope.ai/en/mail-parser/

mail-parser is a production-grade, RFC-compliant email parsing library that goes far beyond a simple wrapper for Python's email module. It turns a raw email into structured Python objects, draws its structure, and reports every defect it finds, so that malformed mail becomes evidence instead of a silent misread.

mail-parser is the battle-tested foundation of SpamScope, an email security and threat analysis platform, and has proven itself in production environments where accuracy and security matter most.

Table of contents

  • Why mail-parser
  • Installation
    • Quick install
    • Outlook .msg support
    • Development installation
  • Quick start
  • The parsed mail
    • Parsing functions and input handling
    • Properties
    • Attachments
    • Delivery path
  • Message structure
    • The MIME tree
    • The drawing
  • Defects
    • What a defect is
    • Where defects appear
    • Catalogue of defects
    • Using defects in a pipeline
    • Examples
    • When the parser reports its own failure
  • Forensic recovery
    • Addresses
    • Received trace
    • Dates
    • Text, charsets and payloads
    • MIME parameters and boundaries
    • Resource limits
  • Command line
  • Exception hierarchy
  • Reporting security issues
  • Docker deployment
  • mail-parser in the ecosystem
  • Support mail-parser
  • License and authors
  • Working with coding agents

Why mail-parser

  • Security-first design. Built for email security analysis and digital forensics: it detects malformed structures, hidden content and RFC non-compliance that can hide a payload from a filter or a gateway.
  • Everything is extracted. Headers, plain-text and HTML bodies, attachments with their metadata, the delivery path hop by hop, dates with timezones, custom headers.
  • Three views of every value. Python object, raw header text and JSON, for any workflow.
  • Defects are data. Every RFC violation, malformed boundary or recovered value is reported with its evidence, never dropped and never silently normalized.
  • The structure is visible. One flat list describes the MIME tree, and a text drawing shows headers, delivery path and tree at a glance.
  • Outlook support. .msg files are parsed alongside standard .eml messages.
  • Production-ready. Python 3.9 and later, extensive test suite, security reviews on every change (SECURITY.md).

Installation

Use the latest patch release of your Python series. mail-parser parses with Python's email package, and older patch releases take quadratic time on a header with many parameters: an 80 KB Content-Type value takes more than a second on Python 3.9.6, 3.11.11, 3.12.8 and 3.13.2, and under 0.1 seconds on 3.10.22, 3.12.16, 3.13.18, 3.14.10 and 3.15.2.

Quick install
pip install mail-parser
Outlook .msg support

Outlook .msg files are converted to .eml before parsing. Two backends exist:

  1. extract-msg (recommended, pure Python): pip install mail-parser[outlook].
  2. msgconvert (deprecated, external Perl tool): the libemail-outlook-message-perl system package (apt-get install libemail-outlook-message-perl on Debian-based systems).

When extract-msg is installed it is used first; only when it is not available does mail-parser fall back to msgconvert, logging a deprecation warning. With neither backend, parse_from_file_msg() raises MailParserOSError. A malformed .msg (not OLE, truncated, corrupt) read with extract-msg raises MailParserOutlookError, with the library's exception as __cause__.

⚠️ Deprecated: the msgconvert backend will be removed in a future release. Migrate with pip install mail-parser[outlook].

💥 Breaking change: the default .msg backend changed. The two converters produce different intermediate .eml output, so some parsed fields (header ordering, encoding edge cases, attachment naming) can differ from the previous msgconvert-only behaviour. Downstream code asserting on exact .msg-derived output may need updating.

Development installation
git clone https://github.com/SpamScope/mail-parser.git
cd mail-parser
uv sync

AGENTS.md holds the commands, the architecture notes and the review requirements.

Quick start

import mailparser

mail = mailparser.parse_from_file("example_mail")

mail.from_  # [('Sender Name', 'sender@example.com')]
mail.to  # [('Recipient', 'recipient@example.com')]
mail.subject  # 'Invoice'
mail.date  # datetime with timezone
mail.attachments  # [{'filename': 'invoice.pdf', 'payload': '...base64...', ...}]
mail.received  # one dict per hop, first hop first
mail.mime_tree  # one dict per MIME part
mail.has_defects  # True when anything needed recovery or broke a rule
mail.defects_categories  # {'AddressHeaderDefect', ...}
mail.mail_json  # the whole parsed mail as JSON

print(mailparser.render_structure(mail))  # headers, delivery path and MIME tree as text

From the command line:

mail-parser -f example_mail -j            # parsed mail as JSON
mail-parser -f example_mail -st           # draw the structure
mail-parser -f example_mail -j --mime-tree  # JSON of the mail, then JSON of the MIME tree

The parsed mail

Parsing functions and input handling
import mailparser

mail = mailparser.parse_from_bytes(byte_mail)  # bytes
mail = mailparser.parse_from_file(f)  # file path, read as bytes
mail = mailparser.parse_from_file_obj(fp)  # file object, opened in binary mode
mail = mailparser.parse_from_string(raw_mail)  # text already decoded by the caller
mail = mailparser.parse_from_file_msg(outlook_mail)  # Outlook .msg
mail = mailparser.MailParser(message)  # an email.message.Message the caller parsed
  • Bytes are the forensic input. File paths are read as bytes, so undecodable octets and the original MIME line endings are preserved just like parse_from_bytes(). Declared charsets apply to the body; UTF-8 recovery applies when the declared decode fails, not by guessing which valid interpretation the sender intended. Undecodable header octets appear as Python's surrogateescape code points (\udcff is the byte FF).
  • Strings are text. parse_from_string() accepts text the caller decoded. It may hold lone surrogates, which are reported as evidence rather than failing the parse.
  • A file object is what it was opened as. parse_from_file_obj() reads a binary file object (open(path, "rb"), sys.stdin.buffer) as bytes. A text file object has already decoded the message, so it is read as a string: an 8-bit attachment is then no longer the octets of the message, its hash differs, and PayloadEncodingDefect reports it. The command line reads --stdin as bytes.
  • A caller's message is never changed. MailParser(message) reads a message parsed with the email package under any policy; message_as_string and the attached containers are flattened through a copy. One limit lies in the email package itself: with the default compat32 policy, email.message_from_string() raises UnicodeEncodeError before mail-parser is involved when Content-Type or Content-Transfer-Encoding holds a lone surrogate. Pass the text to parse_from_string() instead.
Properties

Every parsed element is available in three forms:

  • mail.to: the Python object (list, dict, string or datetime);
  • mail.to_json: the same value as JSON;
  • mail.to_raw: the original header text, exactly as it appears in the message.

Standard headers are properties: bcc, cc, date, delivered_to, from_ (from is a Python keyword), message_id, received, reply_to, subject, to. Address headers return a list of (display_name, address) tuples.

Any other header is reached by replacing hyphens with underscores: mail.X_MSMail_Priority reads X-MSMail-Priority. This convenience, and the _json / _raw suffixes, apply only to attribute access written by you. Names read out of a message, the keys of mail and headers, are looked up literally: a header genuinely named X_Spam_Flag or Subject_json keeps its own name and its own value, and a header named like a method (Parse, Headers_json) is still a header. Attribute names beginning with an underscore are not headers and raise AttributeError.

Computed components:

Property Content
body The text parts (text_plain, then text_html, then text_not_managed) joined with --- mail_boundary --- lines.
text_plain, text_html Lists of the plain-text and HTML body parts. HTML is returned as text, never rendered.
text_not_managed Text parts of other subtypes.
headers One key per header name as written, with its decoded value: address headers as (name, address) tuples (first occurrence), the others as a string, or a list when the header repeats.
attachments One dict per attachment, see Attachments.
received One dict per hop, see Delivery path.
get_server_ipaddress(trust) The sender's IP as seen by the first Received header that contains trust, or None. Never falls back to older, forgeable hops.
to_domains The recipient domains.
timezone The offset of date from UTC in hours, as text ('+1.0'); 0 without a date.
mime_tree One dict per MIME part, see Message structure.
has_defects, defects, defects_categories The defect summary, see Defects.
address_header_defects, received_header_defects, date_header_defects, header_decoding_defects, resource_limit_defects, parser_error_defects The structured diagnostics, always lists.
mail, mail_json Everything above in one dict / JSON document (the structured diagnostics only when nonempty).
mail_partial The same with the main headers only.
message, message_as_string The underlying email.message.Message and the message flattened back to text.

mail.subject removes folding CRLF followed by a space or tab (RFC 5322 section 2.2.3) before decoding encoded words; LF-only folds are accepted too. mail.subject_raw and mail.message keep the original folding. If an encoded word cannot be decoded, the complete literal Subject is kept and header_decoding_defects says why.

Attachments

Each entry of mail.attachments is a dict:

OX Radar and Response Center

Find threats in your stack.

OX Radar can check high-priority threats, like critical package CVEs, against your context.

Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.

Where it’s listed

The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).

  • pypi-releases mail-parser

References

The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.

Powered by Read the latest findings

Scan your whole stack

Group 1261154050 1
Group 1261154050
 

From OX Research Newsroom

Ethersphere Hijacked With Crypto Stealing Malware (1)
npm

Ethersphere Hijacked With Crypto Stealing Malware Via Github & npm

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?
Vulnerability Insights

The 2026 Vulnpocalypse Hits PHP: Four Critical RCEs, but How Dangerous Are They?

Critical Apache HTTP Server Flaw Exposes Web Servers to RCE (1)
CVE

CVE-2026-119618: Critical Apache HTTP Server Flaw Exposes Web Servers to Remote Code Execution

Frame 2085668439 (1)
Group 1261154229