A tool for migrating IMAP accounts into Dovecot format.
Mailgrate is a utility designed to help migrate email accounts from various IMAP servers into the Dovecot mail server format. It handles the conversion process while preserving email metadata, folder structure, and message attributes.
# Clone the repository
git clone https://github.com/nathanaelbonfim/mailgrate.git
# Build the binary
make build# Basic usage
mailgrate --source-server imap.example.com --source-user [email protected] --source-pass password \
--destination-path /var/mail/dovecot/user
# With SSL
mailgrate --source-server imap.example.com --source-port 993 --use-ssl \
--source-user [email protected] --source-pass password \
--destination-path /var/mail/dovecot/user
# Include specific folders only
mailgrate --source-server imap.example.com --source-user [email protected] \
--folders "INBOX,Sent,Important" --destination-path /var/mail/dovecot/user
# Using a YAML file for multiple users
mailgrate --users-file users.yaml --destination-path /var/mail/dovecot--source-server: Source IMAP server address--source-port: Source IMAP port (default: 143)--source-user: Source IMAP username--source-pass: Source IMAP password--use-ssl: Use SSL/TLS for connection--folders: Comma-separated list of folders to migrate (default: all)--destination-path: Path to Dovecot mail directory--concurrent: Number of concurrent migrations (default: 5)--users-file: Path to YAML file containing multiple users to migrate--help: Show help information
You can specify multiple users in a YAML file for batch migration. Create a YAML file with the following structure:
# Example users.yaml file
hosts:
- server: imap.example.com
port: 143
use_ssl: false
users:
- email: [email protected]
password: password1
folders: ["INBOX", "Sent", "Important"]
- email: [email protected]
password: password2
- server: imap.another.com
port: 993
use_ssl: true
users:
- email: [email protected]
password: password3
folders: ["INBOX", "Archive"]
- email: [email protected]
password: password4Then run the migration using:
mailgrate --users-file users.yaml --destination-path /var/mail/dovecot --concurrent 10This will process all users defined in the YAML file, maintaining the folder structure under the destination path.
MIT License - Copyright (c) Nathanael Bonfim