Bulk encrypt your .eml email files on Windows using GPG (Gpg4win) and Python.
Email-Encryption/ # Project root (Git repo)
├── .env # Your PGP key configuration
├── LICENSE # Project license
├── README.md # This guide
├── emails/ # Input folder for plaintext .eml files
│ └── README.md # Notes on email placement
├── encrypted/ # Output folder for encrypted .eml files
│ └── README.md # Notes on encrypted files
├── scripts/
│ └── encrypt_eml.py # Main Python encryption script
└── .git/ # Git metadata (ignore)
- Windows 10/11
- Python 3.x (https://www.python.org/downloads/) with Add to PATH enabled.
- Gpg4win (https://gpg4win.org) for GPG tools and key management.
-
Download and install Gpg4win, accepting default components (GnuPG, Kleopatra).
-
Open System Properties → Environment Variables.
-
Under System variables, edit Path and add two entries:
C:\Program Files (x86)\Gpg4win\binC:\Program Files (x86)\GnuPG\bin
-
Click OK to apply.
-
Verify in PowerShell/CMD:
gpg --version -
Run
kleopatra.exeand import or create your PGP keys.
All required Python packages are pinned in requirements.txt for easy setup and reproducibility. From the project root, run:
pip install -r requirements.txtAt the project root, edit .env to include your PGP key ID or email:
# Set this to your own GPG key (email or key ID)
SELF_KEY=your@emailaddress.here- Place all plaintext
.emlfiles into theemails/directory. - The script will process every
*.emlfound there.
-
Open PowerShell/CMD and navigate to the scripts folder:
cd path\to\Email-Encryption\scripts -
Execute:
python encrypt_eml.py
-
Encrypted files will be created in
../encrypted/with the same filenames.
- Open Thunderbird, go to Local Folders.
- Drag and drop the encrypted
.emlfiles fromencrypted/. - Thunderbird’s OpenPGP built-in support will prompt for your passphrase and render the decrypted content.
© 2025 Lupton Consulting Inc., LLP. Licensed under the terms in LICENSE. Feel free to customize and extend.