257 lines
6.6 KiB
Markdown
257 lines
6.6 KiB
Markdown
# Mail-Migrator
|
|
|
|
Email migration tools untuk memindahkan mailbox IMAP antar server dengan dukungan resume, batch processing, dan insecure mode.
|
|
|
|
## Features
|
|
|
|
- ✅ **Single & Batch Migration**: Migrasi satu akun atau batch dari file CSV
|
|
- ✅ **Resume Support**: Lanjutkan migrasi yang terputus menggunakan BoltDB state tracking
|
|
- ✅ **Insecure Mode**: Terima self-signed certificates dengan flag `--insecure`
|
|
- ✅ **Comprehensive Logging**: Log ke console dan file dengan timestamp
|
|
- ✅ **Mailbox Detection**: Otomatis detect dan migrate semua mailbox/folder
|
|
- ✅ **Batch Processing**: Proses message dalam batch untuk efisiensi
|
|
- ✅ **Error Handling**: Robust error handling dengan retry logic
|
|
- ✅ **Authentication Support**: LOGIN dan AUTHENTICATE PLAIN methods
|
|
- ✅ **Special Characters**: Support password dengan karakter khusus
|
|
- ✅ **Debug Mode**: Detailed logging untuk troubleshooting
|
|
|
|
## Installation
|
|
|
|
### Build from Source
|
|
|
|
```bash
|
|
git clone <repository-url>
|
|
cd mail-migrator
|
|
go mod tidy
|
|
go build .
|
|
```
|
|
|
|
### Download Binary
|
|
|
|
Download binary dari releases page atau build sendiri.
|
|
|
|
## Usage
|
|
|
|
### Single Account Migration
|
|
|
|
```bash
|
|
# Basic migration
|
|
./mail-migrator --src "user@domain.com:password@imap.source.com:993" \
|
|
--dst "user@domain.com:password@imap.dest.com:993" \
|
|
--insecure
|
|
|
|
# With logging
|
|
./mail-migrator --src "user@domain.com:password@imap.source.com:993" \
|
|
--dst "user@domain.com:password@imap.dest.com:993" \
|
|
--insecure --log migration.log
|
|
|
|
# With resume support
|
|
./mail-migrator --src "user@domain.com:password@imap.source.com:993" \
|
|
--dst "user@domain.com:password@imap.dest.com:993" \
|
|
--insecure --resume --log migration.log
|
|
```
|
|
|
|
### Batch Migration
|
|
|
|
1. **Buat file CSV** (contoh: `accounts.csv`):
|
|
```csv
|
|
user1@domain.com:password1@imap.source.com:993,user1@domain.com:password1@imap.dest.com:993
|
|
user2@domain.com:password2@imap.source.com:993,user2@domain.com:password2@imap.dest.com:993
|
|
info@trieltree.co.id:P@ssw0rd123@10.10.11.30:993,info@trieltree.co.id:P@ssw0rd123@10.10.11.24:993
|
|
```
|
|
|
|
2. **Jalankan batch migration**:
|
|
```bash
|
|
./mail-migrator --batch accounts.csv --insecure --resume --log migration.log
|
|
```
|
|
|
|
## URL Format
|
|
|
|
Format URL untuk source dan destination:
|
|
```
|
|
username:password@hostname:port
|
|
```
|
|
|
|
### Contoh:
|
|
- `user@domain.com:mypassword@mail.server.com:993`
|
|
- `info@trieltree.co.id:P@ssw0rd123@10.10.11.30:993`
|
|
|
|
### Password dengan Karakter Khusus
|
|
|
|
Jika password mengandung karakter khusus (`@`, `:`, `/`, dll), gunakan URL encoding:
|
|
- `@` → `%40`
|
|
- `:` → `%3A`
|
|
- `/` → `%2F`
|
|
- `%` → `%25`
|
|
|
|
**Contoh:**
|
|
```bash
|
|
# Password: P@ssw0rd:123/test
|
|
# URL encoded: P%40ssw0rd%3A123%2Ftest
|
|
./mail-migrator --src "user:P%40ssw0rd%3A123%2Ftest@server:993" \
|
|
--dst "user:P%40ssw0rd%3A123%2Ftest@server:993" \
|
|
--insecure
|
|
```
|
|
|
|
## Command Line Options
|
|
|
|
| Flag | Description | Default |
|
|
|------|-------------|---------|
|
|
| `--src` | Source IMAP URL | Required |
|
|
| `--dst` | Destination IMAP URL | Required |
|
|
| `--batch` | CSV file untuk batch migration | - |
|
|
| `--insecure` | Skip SSL certificate verification | false |
|
|
| `--resume` | Resume interrupted migration | false |
|
|
| `--log` | Log file path | - |
|
|
|
|
## Troubleshooting
|
|
|
|
### 1. Authentication Failed
|
|
|
|
**Error**: `LOGIN Authentication failed`
|
|
|
|
**Solusi**:
|
|
1. **Pastikan credential benar**:
|
|
```bash
|
|
# Test dengan IMAP test tool
|
|
cd tools
|
|
go build -o imap-test.exe imap-test.go
|
|
./imap-test.exe <host> <port> <username> <password>
|
|
```
|
|
|
|
2. **Coba format username berbeda**:
|
|
- `username` (tanpa domain)
|
|
- `username@domain.com` (dengan domain)
|
|
- `username@mail.domain.com` (dengan subdomain)
|
|
|
|
3. **Periksa server capabilities**:
|
|
- Tool akan otomatis mencoba LOGIN dan AUTHENTICATE PLAIN
|
|
- Check log untuk melihat supported authentication methods
|
|
|
|
### 2. SSL Certificate Error
|
|
|
|
**Error**: `certificate verify failed`
|
|
|
|
**Solusi**:
|
|
```bash
|
|
# Gunakan flag --insecure untuk self-signed certificates
|
|
./mail-migrator --src "..." --dst "..." --insecure
|
|
```
|
|
|
|
### 3. Connection Timeout
|
|
|
|
**Error**: `connection timeout`
|
|
|
|
**Solusi**:
|
|
1. **Test koneksi manual**:
|
|
```bash
|
|
telnet <hostname> <port>
|
|
# atau
|
|
openssl s_client -connect <hostname>:<port>
|
|
```
|
|
|
|
2. **Periksa firewall dan network**
|
|
3. **Pastikan port benar** (biasanya 993 untuk IMAPS, 143 untuk IMAP)
|
|
|
|
### 4. Resume Migration
|
|
|
|
Jika migration terputus, gunakan `--resume` untuk melanjutkan:
|
|
```bash
|
|
./mail-migrator --src "..." --dst "..." --resume --log migration.log
|
|
```
|
|
|
|
State disimpan di file `state.db` menggunakan BoltDB.
|
|
|
|
### 5. Debug Mode
|
|
|
|
Untuk troubleshooting detail, check log file atau console output:
|
|
```bash
|
|
./mail-migrator --src "..." --dst "..." --log debug.log
|
|
```
|
|
|
|
Log akan menampilkan:
|
|
- Server capabilities
|
|
- Authentication attempts
|
|
- Message copy progress
|
|
- Error details
|
|
|
|
## Tools
|
|
|
|
### IMAP Test Tool
|
|
|
|
Tool untuk test koneksi dan authentication IMAP:
|
|
|
|
```bash
|
|
cd tools
|
|
go build -o imap-test.exe imap-test.go
|
|
./imap-test.exe <host> <port> <username> <password>
|
|
```
|
|
|
|
**Contoh**:
|
|
```bash
|
|
./imap-test.exe 10.10.11.30 993 info@trieltree.co.id P@ssw0rd123
|
|
```
|
|
|
|
Tool ini akan:
|
|
- Test koneksi SSL/TLS
|
|
- Tampilkan server capabilities
|
|
- Test berbagai format username
|
|
- Memberikan feedback detail untuk troubleshooting
|
|
|
|
## Examples
|
|
|
|
### Contoh Sukses Migration
|
|
|
|
```bash
|
|
# Single account
|
|
./mail-migrator --src "info@trieltree.co.id:P@ssw0rd123@10.10.11.30:993" \
|
|
--dst "info@trieltree.co.id:P@ssw0rd123@10.10.11.24:993" \
|
|
--insecure --log migration.log
|
|
|
|
# Output:
|
|
# ✓ Connected to 10.10.11.30:993 as info@trieltree.co.id
|
|
# ✓ Connected to 10.10.11.24:993 as info@trieltree.co.id
|
|
# ✓ Found 6 mailboxes to migrate
|
|
# ✓ INBOX: 17 messages migrated
|
|
# ✓ Migration completed successfully
|
|
```
|
|
|
|
### Batch Migration
|
|
|
|
```bash
|
|
# File: accounts.csv
|
|
info@trieltree.co.id:P@ssw0rd123@10.10.11.30:993,info@trieltree.co.id:P@ssw0rd123@10.10.11.24:993
|
|
user2@domain.com:password2@10.10.11.30:993,user2@domain.com:password2@10.10.11.24:993
|
|
|
|
# Command:
|
|
./mail-migrator --batch accounts.csv --insecure --resume --log batch-migration.log
|
|
```
|
|
|
|
## Technical Details
|
|
|
|
- **Language**: Go
|
|
- **IMAP Library**: github.com/emersion/go-imap
|
|
- **State Storage**: BoltDB
|
|
- **Logging**: Logrus
|
|
- **Authentication**: LOGIN, AUTHENTICATE PLAIN
|
|
- **SSL/TLS**: Support dengan opsi insecure mode
|
|
|
|
## License
|
|
|
|
[Sesuai dengan license file]
|
|
|
|
## Contributing
|
|
|
|
1. Fork repository
|
|
2. Create feature branch
|
|
3. Commit changes
|
|
4. Push to branch
|
|
5. Create Pull Request
|
|
|
|
## Support
|
|
|
|
Jika mengalami masalah:
|
|
1. Check troubleshooting section
|
|
2. Gunakan IMAP test tool untuk debug
|
|
3. Enable debug logging
|
|
4. Create issue dengan log detail |