Parsing EML files
Recipe Difficulty: Easy
Python Version: 2.7 or 3.5
Operating System: Any
The EML file format is widely used for storing email messages, as it is a structured text file that is compatible across multiple email clients. This text file stores email headers, body content, and attachment data as plain text, using base64
to encode binary data and the Quoted-Printable (QP) encoding to store content information.
Getting started
All libraries used in this script are present in Python's standard library. We will use the built-in email
library to read and extract key information from the EML files.
Note
To learn more about the email
library, visit https://docs.python.org/3/library/email.html.
How to do it...
To create an EML parser, we must:
- Accept an argument for an EML file.
- Read values from the headers.
- Parse information from each of the sections of the EML.
- Display this information for ease of review in the console.
How it works...
We start by importing libraries for argument handling, EML processing...