imapcrawler
a python tool to crawl an imap inbox and extract emails as structured records for other tools
IMAP Email Inbox Crawler
A Python tool for crawling emails from an IMAP server, fetching raw email data, and cleaning/parsing the content for later analysis or use in applications like knowledge bases.
Features
- Fetch emails from IMAP servers (including Gmail, Outlook, etc.)
- Support for querying by date ranges, months, or specific days
- Raw email extraction with metadata
- Email content cleaning and parsing (HTML to text, quote removal, etc.)
- Configurable file handling modes (merge, overwrite, raise)
- Persistent configuration storage
- Command-line interface for easy automation
Installation
To install this package in development mode, run:
pip install imapcrawler
The package has the following optional dependencies which will improve quality of text extraction:
tqdmbeautifulsoup4python-dateutilmail-parser-reply
the package can be installed with all optional dependencies like this
pip install imapcrawler[all]
Usage
NOTE: if installed via pip you can either use python imapcrawler.py or just imapcrawler.
Basic Commands
-
Set up configuration:
python imapcrawler.py config-set --server imap.example.com --email user@example.com
-
Download raw emails:
python imapcrawler.py download --month 2023-06 --limit 100
-
Clean downloaded emails:
python imapcrawler.py clean
Command Reference
config-set
Set persistent configuration values interactively or via arguments.
config-show
Display current configuration.
config-clear
Clear all configuration values.
config-default
Reset configuration to factory defaults.
download
Fetch raw emails from IMAP server.
Options:
--date- Specific date (YYYY-MM-DD)--month- Month to query (YYYY-MM)--limit- Limit number of emails (-1 for all)--diff- Skip already known emails--filepath_raw- Output file for raw emails--filepath_clean- Output file for cleaned emails
clean
Process raw emails and save cleaned version.
peek-raw / peek-clean
Show a random email from raw or cleaned files.
Configuration File
Configuration is stored in ~/.imapcrawler_config.json and includes:
- Server address
- Email address
- File paths for raw and cleaned emails
- File handling mode
Output Files
emails_raw.jsonl: Raw email data with full metadataemails.jsonl: Cleaned email data with processed content
Example Workflow
# Configure once
python imapcrawler.py config-set --server imap.gmail.com --email user@gmail.com
# Download emails from June 2023
python imapcrawler.py download --month 2023-06 --limit 500
# Clean the downloaded emails
python imapcrawler.py clean
# View a sample
python imapcrawler.py peek-clean
Notes
- Passwords are prompted securely when not provided via command line
- The tool handles large email volumes efficiently with progress bars
- Supports various IMAP servers including Gmail, Outlook, and custom servers
- Email cleaning removes HTML tags, quoted text, and signature blocks
Metadata
Release files for imapcrawler 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imapcrawler-0.1.2.tar.gz | 13.2 kB | Without provenance | Details for imapcrawler-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imapcrawler-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for imapcrawler-0.1.2-py3-none-any.whl |
Total release size: 26.7 kB
Release files / imapcrawler-0.1.2.tar.gz
| Download URL | imapcrawler-0.1.2.tar.gz |
|---|---|
| Size | 13.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0d7f906ea0faadbe45eb84242fcb258ab0e945500a59ce5120413017fb767f48
|
|
BLAKE2b-256 checksum How to use checksums |
82e22ad04cbb52bfb10d718c5090631c2cd3f5611242c946232123fb0719aaf8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Release files / imapcrawler-0.1.2-py3-none-any.whl
| Download URL | imapcrawler-0.1.2-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
77a19b57ff88c8efbeef63d2b9a3c7222fef159f9104d630c297289b8bff1d9f
|
|
BLAKE2b-256 checksum How to use checksums |
757ecc67a4f9ffbe9206f249cc95a24cf59044b0165bd1faf7cdcd18aedfc296
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.9
|
Security for imapcrawler 0.1.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.