Skip to main content

Parse EML file and export the information extracted as JSON.

Project description

EMLMailReader logo

PyPI version Static Badge

Overview

EMLMailReader is a comprehensive Python library designed to parse and extract information from EML (Email Message Format) files. The library provides a robust solution for reading email files, extracting headers, body content, attachments, and handling complex MIME structures with support for various encoding formats.

Key Features

  • Complete EML Parsing: Parse standard EML files with full MIME support
  • Multi-part Message Support: Handle complex email structures with nested MIME parts
  • Attachment Extraction: Extract and save file attachments with proper metadata
  • Encoding Support: Decode Base64, Quoted-Printable, and other transfer encodings
  • Address Parsing: Parse and manage email addresses with display names
  • Logging Integration: Comprehensive logging for debugging and monitoring
  • Exception Handling: Custom exceptions for specific error scenarios

Quick Start

Installation

pip install emlmailreader

Basic Usage

from EMLMailReader import MailReader, LoggingMode

# Initialize the mail reader
reader = MailReader(logging_mode=LoggingMode.CONSOLE)

# Parse an EML file
message = reader.get_email("/path/to/email.eml")

if message:
    # Access basic email information
    print(f"From: {message.From}")
    print(f"Subject: {message.Subject}")
    print(f"Date: {message.Date}")

    # Access recipients
    print(f"To: {message.To}")
    print(f"Cc: {message.Cc}")

    # Access body content
    print(f"Body: {message.Body}")

    # Check for attachments
    if message.Attachments.length() > 0:
        print(f"Found {message.Attachments.length()} attachments")

        # Save attachments to a folder
        message.save_attachments("/path/to/output/folder")

    # Export message as JSON
    json_data = message.export_as_json()
    print(json_data)

License

This library is distributed under the terms specified in the LICENSE file.

Support

For issues, questions, or contributions, please refer to the project repository.

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

emlmailreader-1.0.4.tar.gz (33.6 kB view details)

Uploaded Source

Built Distribution

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

emlmailreader-1.0.4-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file emlmailreader-1.0.4.tar.gz.

File metadata

  • Download URL: emlmailreader-1.0.4.tar.gz
  • Upload date:
  • Size: 33.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for emlmailreader-1.0.4.tar.gz
Algorithm Hash digest
SHA256 cd4c62f2eb081aa4fd1a6bb9be8ca16cf6d3e8cf1292619dcb84561ff598b282
MD5 25668c1b8e05b1ec98d2e250832c041e
BLAKE2b-256 cc76d0c5035df915f74fffcc285ebcde704f6cbf74525057cb9f9d79058ff1f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for emlmailreader-1.0.4.tar.gz:

Publisher: release.yml on codadel/EMLMailReader

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

File details

Details for the file emlmailreader-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: emlmailreader-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for emlmailreader-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 cefd175ba39f689dea2fef183846ce0c0776ba1449387163c789e290cc56f9a9
MD5 2e515d9a817b816d0520190caf2956a0
BLAKE2b-256 6d87ec05fb668cc8984af3735b9061082220c6460508e95de2ea4745036d5d3b

See more details on using hashes here.

Provenance

The following attestation bundles were made for emlmailreader-1.0.4-py3-none-any.whl:

Publisher: release.yml on codadel/EMLMailReader

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

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