A production-ready Python tool for migrating emails between IMAP accounts with a beautiful Rich TUI dashboard and Discord webhook notifications.
- π Multi-Account Migration: Migrate emails from multiple source accounts to destination accounts
- π Live Dashboard: Real-time Rich TUI showing progress, statistics, and errors
- π Discord Notifications: Get notified on start, completion, errors, and periodic updates
- βοΈ Flexible Configuration: Interactive wizard or YAML/JSON config files
- π Fully Async: High-performance async/await implementation
- π‘οΈ Production Ready: Error handling, logging, graceful shutdown
- Python 3.12+
uvpackage manager
If you don't have uv installed:
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# Linux/Mac
curl -LsSf https://astral.sh/uv/install.sh | shuv pip install -e .Or using uv directly:
uv syncRun the interactive configuration wizard:
uv run cli.py interactiveThis will guide you through:
- Setting up source and destination IMAP accounts
- Configuring folders to migrate
- Setting up Discord webhook (optional)
The wizard will save your configuration to a YAML file.
Once you have a config file:
uv run cli.py run --config config.yamlCheck if your configuration is valid:
uv run cli.py check --config config.yamlCreate a config.yaml file (see config.example.yaml for template):
accounts:
- name: "my-email"
source:
host: "imap.example.com"
port: 993
username: "user@example.com"
password: "password"
use_ssl: true
destination:
host: "imap.destination.com"
port: 993
username: "user@destination.com"
password: "password"
use_ssl: true
folders: [] # Empty = all folders
skip_folders: ["Trash", "Spam"]
discord:
webhook_url: "https://discord.com/api/webhooks/..."
notify_on_start: true
notify_on_complete: true
notify_on_error: true
periodic_updates: false
update_interval_minutes: 30host: IMAP server hostnameport: IMAP port (usually 993 for SSL, 143 for non-SSL)username: IMAP username/emailpassword: IMAP passworduse_ssl: Use SSL/TLS (default: true)verify_ssl: Verify SSL certificates (default: true)
name: Unique name for this account migrationfolders: List of folders to migrate (empty = all folders)skip_folders: List of folders to skip
webhook_url: Discord webhook URL (optional)notify_on_start: Send notification when migration startsnotify_on_complete: Send notification when migration completesnotify_on_error: Send notification on errorsperiodic_updates: Send periodic progress updatesupdate_interval_minutes: Minutes between periodic updates
# Interactive configuration wizard
uv run cli.py interactive
# Run migration from config file
uv run cli.py run --config config.yaml
# Validate configuration
uv run cli.py check --config config.yamlFor server deployments, use the run command with a config file:
uv run cli.py run --config /path/to/config.yamlThe tool will:
- Run without any user interaction
- Log to
migration.log - Send Discord notifications (if configured)
- Handle errors gracefully
The Rich TUI dashboard shows:
- Global Progress Bar: Overall migration progress
- Accounts Table: Per-account status, progress, and statistics
- Status Panel: Elapsed time, throughput, totals
- Errors Panel: Recent errors (if any)
The dashboard updates in real-time and provides a clear view of the migration status.
Logs are written to:
- Console: Real-time output with Rich formatting
- File:
migration.logwith timestamps and structured logs
If configured, the tool sends Discord webhook messages for:
- Migration Started: When migration begins
- Migration Completed: When all migrations finish
- Account Errors: When an account migration fails
- Periodic Updates: Progress updates (if enabled)
- Individual message failures are tracked and logged
- Account-level errors are reported to Discord (if configured)
- Graceful shutdown on Ctrl+C
- Failed messages are counted but don't stop the migration
email_migrator/
βββ migrator/
β βββ __init__.py
β βββ config.py # Configuration management
β βββ models.py # Data models
β βββ imap_client.py # IMAP operations
β βββ migration_worker.py # Migration logic
β βββ dashboard.py # Rich TUI dashboard
β βββ discord_notifier.py # Discord webhooks
β βββ main.py # Main orchestrator
βββ cli.py # CLI interface
βββ pyproject.toml # Project configuration
βββ config.example.yaml # Example configuration
βββ README.md # This file
# Install dev dependencies
uv pip install -e ".[dev]"
# Run tests (if available)
uv run pytestThe codebase uses:
- Type hints throughout
- Async/await for I/O operations
- Rich for terminal UI
- Clean architecture with separation of concerns
- Verify IMAP server host and port
- Check SSL settings (use_ssl, verify_ssl)
- Ensure credentials are correct
- Check firewall/network settings
- Check
migration.logfor detailed error messages - Verify source and destination folders exist
- Ensure sufficient permissions on destination account
- Check Discord webhook URL if notifications fail
- Migration runs concurrently for all accounts
- Messages are migrated sequentially within each folder
- Large mailboxes may take significant time
This project is provided as-is for email migration purposes.
Contributions are welcome! Please ensure:
- Code follows existing style
- Type hints are used
- Async operations are properly handled
- Error handling is comprehensive
For issues or questions:
- Check
migration.logfor errors - Validate configuration with
checkcommand - Review Discord notifications (if configured)