eml-parser

python eml parser module

Latest version: 3.0.1 registry icon
Maintenance score
64
Safety score
96
Popularity score
18
Check your open source dependency risks. Get immediate insight about security, stability and licensing risks.
Security
  Vulnerabilities
Version Suggest Low Medium High Critical
3.0.1 0 0 0 0 0
3.0.0 0 0 0 0 0
2.0.1 0 0 0 0 0
2.0.0 0 0 1 0 0
1.17.5 0 0 1 0 0
1.17.4 0 0 1 0 0
1.17.3 0 0 1 0 0
1.17.2 0 0 1 0 0
1.17.1 0 0 1 0 0
1.17.0 0 0 1 0 0
1.16.0 0 0 1 0 0
1.15.0 0 0 1 0 0
1.14.8 0 0 1 0 0
1.14.7 0 0 1 0 0
1.14.6 0 0 1 0 0
1.14.5 0 0 1 0 0
1.14.4 0 0 1 0 0
1.14.3 0 0 1 0 0
1.14.2 0 0 1 0 0
1.14.1 0 0 1 0 0
1.14.0 0 0 1 0 0
1.13.0 0 0 1 0 0
1.12.0 0 0 1 0 0
1.11.7 0 0 1 0 0
1.11.6 0 0 1 0 0
1.11.5 0 0 1 0 0
1.11.4 0 0 1 0 0
1.11.2 0 0 1 0 0
1.11.1 0 0 1 0 0
1.11 0 0 1 0 0
1.10 0 0 1 0 0
1.9 0 0 1 0 0
1.8 0 0 1 0 0
1.7 0 0 1 0 0
1.6 0 0 1 0 0
1.5 0 0 1 0 0
1.4 0 0 1 0 0
1.3 0 0 1 0 0
1.1 0 0 1 0 0
1.0 0 0 1 0 0
0.9 0 0 1 0 0

Stability
Latest release:

3.0.1 - This version is safe to use because it has no known security vulnerabilities at this time. Find out if your coding project uses this component and get notified of any reported security vulnerabilities with Meterian-X Open Source Security Platform

Licensing

Maintain your licence declarations and avoid unwanted licences to protect your IP the way you intended.

GPL-3.0-or-later   -   GNU General Public License v3.0 or later

Not a wildcard

Not proprietary

OSI Compliant


AGPL-3.0   -   GNU Affero General Public License v3.0

Not a wildcard

Not proprietary

OSI Compliant



Documentation Status PyPI PyPI pyversions

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.

For the changelog, please see CHANGELOG.md.

Installation:

pip install eml_parser[filemagic]

⚠️ Note: If you don't want to / cannot use file-magic (e.g. if you are using python-magic), install via:

pip install eml_parser

Known Issues

OSX users

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

Example usage:

import datetime
import json
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()

ep = eml_parser.EmlParser()
parsed_eml = ep.decode_email_bytes(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"
        }
      ]
    }
  }