Name | eml-parser JSON |
Version |
2.0.0
JSON |
| download |
home_page | None |
Summary | Python EML parser library |
upload_time | 2024-10-02 22:07:48 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | AGPLv3+ |
keywords |
email
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
[](https://codebeat.co/projects/github-com-govcert-lu-eml_parser-master)
[](http://eml-parser.readthedocs.io)
[](https://badge.fury.io/py/eml-parser)
[](https://pypi.python.org/pypi/eml-parser/)
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](CHANGELOG.md).
### Installation:
```shell script
pip install eml_parser[filemagic]
```
:warning: **Note:** If you don't want to / cannot use file-magic (e.g. if you are using python-magic), install via:
```shell script
pip install eml_parser
```
### Known Issues
#### **OSX** users
Make sure to install libmagic, else eml_parser will not work.
### Example usage:
```python
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:
```json
{
"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"
}
]
}
}
```
Raw data
{
"_id": null,
"home_page": null,
"name": "eml-parser",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "email",
"author": null,
"author_email": "Georges Toth <georges.toth@govcert.etat.lu>",
"download_url": "https://files.pythonhosted.org/packages/8f/52/98b93d7352e79f981fafebca347d7d8d9d6c686f9d9f005814ec7d8d52cb/eml_parser-2.0.0.tar.gz",
"platform": null,
"description": "[](https://codebeat.co/projects/github-com-govcert-lu-eml_parser-master)\n[](http://eml-parser.readthedocs.io)\n[](https://badge.fury.io/py/eml-parser)\n[](https://pypi.python.org/pypi/eml-parser/)\n\neml_parser serves as a python module for parsing eml files and returning various\ninformation found in the e-mail as well as computed information.\n\nExtracted and generated information include but are not limited to:\n- attachments\n - hashes\n - names\n- from, to, cc\n- received servers path\n- subject\n- list of URLs parsed from the text content of the mail (including HTML body/attachments)\n\nPlease feel free to send me your comments / pull requests.\n\nFor the changelog, please see [CHANGELOG.md](CHANGELOG.md).\n\n### Installation:\n```shell script\npip install eml_parser[filemagic]\n```\n\n:warning: **Note:** If you don't want to / cannot use file-magic (e.g. if you are using python-magic), install via:\n```shell script\npip install eml_parser\n```\n\n### Known Issues\n#### **OSX** users\nMake sure to install libmagic, else eml_parser will not work.\n\n\n### Example usage:\n```python\nimport datetime\nimport json\nimport eml_parser\n\n\ndef json_serial(obj):\n if isinstance(obj, datetime.datetime):\n serial = obj.isoformat()\n return serial\n\n\nwith open('sample.eml', 'rb') as fhdl:\n raw_email = fhdl.read()\n\nep = eml_parser.EmlParser()\nparsed_eml = ep.decode_email_bytes(raw_email)\n\nprint(json.dumps(parsed_eml, default=json_serial))\n```\n\n\nWhich gives for a minimalistic EML file something like this:\n```json\n {\n \"body\": [\n {\n \"content_header\": {\n \"content-language\": [\n \"en-US\"\n ]\n },\n \"hash\": \"6c9f343bdb040e764843325fc5673b0f43a021bac9064075d285190d6509222d\"\n }\n ],\n \"header\": {\n \"received_src\": null,\n \"from\": \"john.doe@example.com\",\n \"to\": [\n \"test@example.com\"\n ],\n \"subject\": \"Sample EML\",\n \"received_foremail\": [\n \"test@example.com\"\n ],\n \"date\": \"2013-04-26T11:15:47+00:00\",\n \"header\": {\n \"content-language\": [\n \"en-US\"\n ],\n \"received\": [\n \"from localhost\\tby mta.example.com (Postfix) with ESMTPS id 6388F684168\\tfor <test@example.com>; Fri, 26 Apr 2013 13:15:55 +0200\"\n ],\n \"to\": [\n \"test@example.com\"\n ],\n \"subject\": [\n \"Sample EML\"\n ],\n \"date\": [\n \"Fri, 26 Apr 2013 11:15:47 +0000\"\n ],\n \"message-id\": [\n \"<F96257F63EAEB94C890EA6CE1437145C013B01FA@example.com>\"\n ],\n \"from\": [\n \"John Doe <john.doe@example.com>\"\n ]\n },\n \"received_domain\": [\n \"mta.example.com\"\n ],\n \"received\": [\n {\n \"with\": \"esmtps id 6388f684168\",\n \"for\": [\n \"test@example.com\"\n ],\n \"by\": [\n \"mta.example.com\"\n ],\n \"date\": \"2013-04-26T13:15:55+02:00\",\n \"src\": \"from localhost by mta.example.com (postfix) with esmtps id 6388f684168 for <test@example.com>; fri, 26 apr 2013 13:15:55 +0200\"\n }\n ]\n }\n }\n```\n",
"bugtrack_url": null,
"license": "AGPLv3+",
"summary": "Python EML parser library",
"version": "2.0.0",
"project_urls": {
"Changelog": "https://github.com/GOVCERT-LU/eml_parser/blob/master/CHANGELOG.md",
"Documentation": "https://eml-parser.readthedocs.io/",
"Homepage": "https://github.com/GOVCERT-LU/eml_parser",
"Source": "https://github.com/GOVCERT-LU/eml_parser",
"Tracker": "https://github.com/GOVCERT-LU/eml_parser/issues"
},
"split_keywords": [
"email"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6af0ed7f0b1a002df79bf09270382f2a22392b70f53959a5b0a34284a82e84bf",
"md5": "7498cde7fef2137fb7ca64077226ab55",
"sha256": "1885ca8cb2db645dc4f29dfd6947ed84d2debbb1c0531bc542f0091089d48ab2"
},
"downloads": -1,
"filename": "eml_parser-2.0.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7498cde7fef2137fb7ca64077226ab55",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 35089,
"upload_time": "2024-10-02T22:07:47",
"upload_time_iso_8601": "2024-10-02T22:07:47.470351Z",
"url": "https://files.pythonhosted.org/packages/6a/f0/ed7f0b1a002df79bf09270382f2a22392b70f53959a5b0a34284a82e84bf/eml_parser-2.0.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8f5298b93d7352e79f981fafebca347d7d8d9d6c686f9d9f005814ec7d8d52cb",
"md5": "6d75ac6b69394822f4219ec24fe896e3",
"sha256": "be88a77c4b79fc1f5e17091c3a587b12c18203347144d5c0977b925707c491e3"
},
"downloads": -1,
"filename": "eml_parser-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "6d75ac6b69394822f4219ec24fe896e3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 1005039,
"upload_time": "2024-10-02T22:07:48",
"upload_time_iso_8601": "2024-10-02T22:07:48.662383Z",
"url": "https://files.pythonhosted.org/packages/8f/52/98b93d7352e79f981fafebca347d7d8d9d6c686f9d9f005814ec7d8d52cb/eml_parser-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-02 22:07:48",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "GOVCERT-LU",
"github_project": "eml_parser",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "eml-parser"
}