{"id":7205,"library":"eml-parser","title":"EML Parser Library","description":"eml-parser is a Python library designed for parsing EML (Email Message) files, extracting headers, body content, attachments, and other email components into a structured dictionary. It is currently at version 3.0.0 and maintains an active development pace with releases for new features, bug fixes, and Python version compatibility.","status":"active","version":"3.0.0","language":"en","source_language":"en","source_url":"https://github.com/GOVCERT-LU/eml_parser","tags":["email","eml","parser","security","forensics"],"install":[{"cmd":"pip install eml-parser","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Requires Python 3.10 or newer due to modern typing syntax and EOL of older Python versions.","package":"python","optional":false}],"imports":[{"symbol":"EmlParser","correct":"from eml_parser import EmlParser"}],"quickstart":{"code":"from eml_parser import EmlParser\n\neml_content = \"\"\"\nFrom: sender@example.com\nTo: receiver@example.com\nSubject: Test Email\nDate: Thu, 1 Jan 2023 12:00:00 +0000\nContent-Type: text/plain; charset=\"utf-8\"\n\nThis is a sample email body.\n\"\"\"\n\n# Initialize the parser\nparser = EmlParser()\n\n# Parse the EML content from a string\nparsed_eml = parser.parse_from_string(eml_content)\n\n# Print some extracted data\nprint(f\"From: {parsed_eml['header']['from']}\")\nprint(f\"Subject: {parsed_eml['header']['subject']}\")\nif parsed_eml['body']:\n    print(f\"Body content: {parsed_eml['body'][0]['content']}\")\n\n# Example for parsing from a file\n# with open('path/to/your.eml', 'rb') as f:\n#     file_content = f.read()\n#     parsed_eml_file = parser.parse_from_string(file_content.decode('utf-8', errors='ignore'))\n#     print(f\"File Subject: {parsed_eml_file['header']['subject']}\")\n","lang":"python","description":"This quickstart demonstrates how to initialize the EmlParser and parse EML content from a string. The parsed data is returned as a dictionary, allowing easy access to headers, body, and other elements. An example of how to parse from a file is also included as a comment."},"warnings":[{"fix":"Upgrade your Python environment to 3.10 or newer, or pin `eml-parser<3.0.0` if you must use an older Python version.","message":"Version 3.0.0 and newer require Python 3.10 or higher. Running on older Python versions will result in `SyntaxError` or `ModuleNotFoundError` for incompatible type hints.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Review your code for compatibility with Python 3.10+ typing syntax and update accordingly. Most basic usage should be unaffected.","message":"The typing syntax was upgraded for Python 3.10+ in v3.0.0. If you have custom code extending or directly interacting with internal types, it might require adjustments.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Consult the official documentation for custom policy options and implement one if the default behavior no longer meets your requirements.","message":"Version 2.0.0 introduced support for custom parsing policies. If your application relies on specific parsing behaviors that might have been influenced by new policy options, review if a custom policy is needed.","severity":"gotcha","affected_versions":">=2.0.0"},{"fix":"Review the parsing options and explicitly configure `EmlParser` settings if you need to disable or fine-tune these new validation behaviors to match prior results.","message":"Starting from v1.17.0, new validation options were added for URLs, email addresses, and IP addresses (e.g., Public Suffix List, `ip_force_routable`, `domain_force_tld`). This might cause previously parsed 'valid' items to be filtered out.","severity":"gotcha","affected_versions":">=1.17.0"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Run `pip install eml-parser` to install the package.","cause":"The `eml-parser` library is not installed in your current Python environment, or the environment is not active.","error":"ModuleNotFoundError: No module named 'eml_parser'"},{"fix":"Upgrade your Python interpreter to version 3.10 or newer. Alternatively, if you cannot upgrade Python, install an older compatible version of the library: `pip install eml-parser<3.0.0`.","cause":"You are attempting to run `eml-parser` version 3.0.0 or higher on a Python version older than 3.10. The library uses modern Python 3.10+ typing syntax.","error":"SyntaxError: invalid syntax (some_file.py, line X)"},{"fix":"Always check for the existence of keys before accessing them, especially when dealing with potentially non-standard EML files. Use `.get()` with a default value, or wrap access in a `try-except KeyError` block, or use `if key in dict:`.","cause":"The expected key (e.g., 'subject', 'from') does not exist in the parsed EML header or body dictionary for the specific email being processed. This often happens with malformed or unusual EML files.","error":"KeyError: 'subject'"}]}