Replace third-party POP3 client with a custom implementation using native-tls for direct TLS socket communication. This change ensures email messages are retrieved as raw bytes without encoding conversions that could corrupt email data. Key improvements: - Direct byte-level message retrieval preserves original email structure - Proper handling of POP3 byte-stuffing (doubled leading dots) - Eliminates dependency on rust-pop3-client which performed unwanted string conversions and line ending modifications - Uses only native-tls for TLS connections (already a project dependency)
POP to IMAP Importer
A Rust application that downloads emails from a POP3 server and imports them into an IMAP server's INBOX.
Features
- POP3 to IMAP Migration: Downloads all emails from a POP3 server and imports them to IMAP
- IMAP Email Normalization: Fix existing malformed emails already in your IMAP inbox
- Secure TLS connections
- Environment-based configuration
- Automatic email header normalization (RFC 5322 compliance)
- Fixes improperly formatted header continuation lines
- Ensures continuation lines start with proper whitespace
- Safe operation with dry-run mode and confirmation prompts
Setup
-
Copy
.env.exampleto.env:cp .env.example .env -
Edit
.envwith your server credentials:# POP3 Source Server Configuration POP3_HOST=pop.example.com POP3_PORT=995 POP3_USERNAME=your_pop3_username POP3_PASSWORD=your_pop3_password # IMAP Destination Server Configuration IMAP_HOST=imap.example.com IMAP_PORT=993 IMAP_USERNAME=your_imap_username IMAP_PASSWORD=your_imap_password
Usage
POP3 to IMAP Migration
Run the main importer to migrate emails from POP3 to IMAP:
cargo run --bin pop-to-imap
# or in release mode
cargo run --release --bin pop-to-imap
Normalize Existing IMAP Emails
If you already have malformed emails in your IMAP inbox, use the normalization tool:
# Dry run to see what would be changed
cargo run --release --bin normalize-imap -- --dry-run
# Actually normalize the emails (will prompt for confirmation)
cargo run --release --bin normalize-imap
# Skip confirmation prompt
cargo run --release --bin normalize-imap --yes
Note: The normalize-imap tool will:
- Fetch all emails from your IMAP INBOX
- Analyze which emails have malformed headers
- Show you a summary of what needs to be fixed
- Delete and re-import only the emails that need normalization
- Keep emails that are already RFC 5322 compliant unchanged
Description
Languages
Rust
90.5%
Makefile
5.6%
Dockerfile
3.9%