Skip to main content
Code Health Code issues https://travis-ci.org/GOVCERT-LU/eml_parser.svg?branch=static_types Documentation Status https://badge.fury.io/py/eml-parser.svg

eml_parser serves as a python module for parsing eml files and returning various information found in the e-mail as well as computed information.

Extracted and generated information include but are not limited to:

  • attachments - hashes - names

  • from, to, cc

  • received servers path

  • subject

  • list of URLs parsed from the text content of the mail (including HTML body/attachments)

Please feel free to send me your comments / pull requests.

Install the latest version using pip:

pip install eml-parser

Note for OSX users:

Make sure to install libmagic, else eml_parser will not work.

Warning:

This release is only compatible with Python3. The last release to be compatible with
Python2 is v1.2. If you do require Python2 support, please download that version.
You are strongly encouraged though to use Python3 as there are many parsing improvements
and much better RFC support.

Example on how to use:

import eml_parser


def json_serial(obj):
    if isinstance(obj, datetime.datetime):
        serial = obj.isoformat()
        return serial


with open('sample.eml', 'rb') as fhdl:
    raw_email = fhdl.read()

parsed_eml = eml_parser.eml_parser.decode_email_b(raw_email)

print(json.dumps(parsed_eml, default=json_serial))

Which gives for a minimalistic EML file something like this:

{
  "body": [
    {
      "content_header": {
        "content-language": [
          "en-US"
        ]
      },
      "hash": "6c9f343bdb040e764843325fc5673b0f43a021bac9064075d285190d6509222d"
    }
  ],
  "header": {
    "received_src": null,
    "from": "john.doe@example.com",
    "to": [
      "test@example.com"
    ],
    "subject": "Sample EML",
    "received_foremail": [
      "test@example.com"
    ],
    "date": "2013-04-26T11:15:47+00:00",
    "header": {
      "content-language": [
        "en-US"
      ],
      "received": [
        "from localhost\tby mta.example.com (Postfix) with ESMTPS id 6388F684168\tfor <test@example.com>; Fri, 26 Apr 2013 13:15:55 +0200"
      ],
      "to": [
        "test@example.com"
      ],
      "subject": [
        "Sample EML"
      ],
      "date": [
        "Fri, 26 Apr 2013 11:15:47 +0000"
      ],
      "message-id": [
        "<F96257F63EAEB94C890EA6CE1437145C013B01FA@example.com>"
      ],
      "from": [
        "John Doe <john.doe@example.com>"
      ]
    },
    "received_domain": [
      "mta.example.com"
    ],
    "received": [
      {
        "with": "esmtps id 6388f684168",
        "for": [
          "test@example.com"
        ],
        "by": [
          "mta.example.com"
        ],
        "date": "2013-04-26T13:15:55+02:00",
        "src": "from localhost by mta.example.com (postfix) with esmtps id 6388f684168 for <test@example.com>; fri, 26 apr 2013 13:15:55 +0200"
      }
    ]
  }
}

Release files for eml-parser 1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eml-parser 1.8
File Size Uploaded
eml_parser-1.8.tar.gz 16.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eml-parser 1.8
File Interpreter ABI Platform
eml_parser-1.8-py3-none-any.whl Python 3 none any Details

Total release size: 49.4 kB

Release files / eml_parser-1.8.tar.gz

Download URL eml_parser-1.8.tar.gz
Size 16.3 kB
Tags Source
SHA-256 checksum
How to use checksums
24d313f47869a7982add3c7a64562e8453170dc98f4fe60e7b38e1fa4f9f8fb5
BLAKE2b-256 checksum
How to use checksums
f3343b35988b2d4d10573000cf725e398fb096aa669e253110bbb5493dff9afc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / eml_parser-1.8-py3-none-any.whl

Download URL eml_parser-1.8-py3-none-any.whl
Size 33.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4be4ce108ec8ae73f2f3bd14ae78c6afabc3e35955b17e43a74ff524b598b0fe
BLAKE2b-256 checksum
How to use checksums
44390fa290b2d913c9c098ca62648d5fface4ccb76949b24069548ee6eea622a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

3.0.4

1 release file

3.0.3

1 release file

3.0.2

1 release file

3.0.1

1 release file

3.0.0

1 release file

2.0.1

1 release file

2.0.0

2 release files

1.17.4

2 release files

1.17.3

2 release files

1.17.2

2 release files

1.17.1

2 release files

1.17.0

1 release file

1.16.0

1 release file

1.15.0

1 release file

1.14.8

1 release file

1.14.7

1 release file

1.14.6

1 release file

1.14.5

1 release file

1.14.4

1 release file

1.14.3

1 release file

1.14.2

1 release file

1.14.1

1 release file

1.14.0

1 release file

1.13.0

1 release file

1.12.0

1 release file

1.11.7

1 release file

1.11.6

2 release files

1.11.5

2 release files

1.11.4

2 release files

1.11.2

2 release files

1.11.1

2 release files

1.11

2 release files

1.10

1 release file

1.9

1 release file

This release

1.8 This release

2 release files

1.7

2 release files

1.6

2 release files

1.5

2 release files

1.4

2 release files

1.3

2 release files

1.1

1 release file

1.0

1 release file

0.9

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page