cPanel Webmail迁移:如何批量迁移多邮箱账户及其文件夹?
Hey there, let's cut through the tedious one-by-one Horde exports and get this bulk migration sorted for your client. Since you're on Site5 hosting with WordPress, here are practical, automation-focused solutions tailored to your setup:
Option 1: Use G Suite's Official Bulk IMAP Migration (Easiest Route)
G Suite has a built-in tool that handles bulk migrations directly from your Site5 IMAP server—no manual exports required. Here's how to set it up:
- Log into your G Suite Admin Console, navigate to Data migration > Email
- Select IMAP as the source type, then enter Site5's IMAP details:
- IMAP server:
mail.yourclientdomain.com - Port:
993(with SSL enabled)
- IMAP server:
- Upload a CSV file listing your client's mailboxes (format:
Email address,Username,Password—use the full email as the username) - Configure migration settings (e.g., migrate all mail or a specific date range) and start the bulk sync
- G Suite will handle the rest in the background; you can monitor progress right in the admin console
Pro tip: If any G Suite accounts have 2FA enabled, generate an App Password for each user and use that instead of their regular password in the CSV.
Option 2: Command-Line Automation with imapsync (More Control)
If you want hands-on control, imapsync is a robust tool for syncing mailboxes between IMAP servers. Site5 allows SSH access (enable it via cPanel if you haven't), so you can set up a batch script:
- Install
imapsync: Connect via SSH and runyum install imapsync(for RHEL/CentOS) orapt-get install imapsync(for Debian/Ubuntu)—skip if it's pre-installed. - Export mailbox list: Grab all email accounts either:
- From cPanel's Email Accounts page (export as CSV)
- Or via phpMyAdmin: Locate the mail account table (usually named
mail_users) and export theemailandpasswordfields (note: passwords might be encrypted—reset them temporarily or get plaintext from cPanel if needed)
- Create a batch script: Make a file named
migrate_mailboxes.shwith this code (adjust paths/credentials to match your setup):
#!/bin/bash # accounts_list.txt format: source_email:source_password:gsuite_email while IFS=: read -r src_email src_pass dest_email; do imapsync --host1 mail.yourclientdomain.com --user1 "$src_email" --password1 "$src_pass" \ --host2 imap.gmail.com --user2 "$dest_email" --password2 "GSITE_APP_PASSWORD" \ --ssl1 --ssl2 --noauthmd5 --exclude-folder "Trash" --exclude-folder "Spam" done < accounts_list.txt
- Run the script: Make it executable with
chmod +x migrate_mailboxes.sh, then run./migrate_mailboxes.sh—it will sync each mailbox one after another.
Option 3: Direct Database Export (If Horde Uses MySQL Storage)
Some Horde setups store mail in a MySQL database (check phpMyAdmin for a database named horde_*):
- Log into phpMyAdmin, locate the Horde database, and export the entire database (or specific tables like
horde_mailandhorde_imap_cache) - Use a conversion tool like
mb2mboxto turn the Horde database format into standard MBOX files - Upload the MBOX files to G Suite using either the admin console's bulk import tool or a script like
gmvault
Critical Pre-Migration Checks
- Test first: Sync one mailbox fully before running bulk operations to catch credential or server setting issues
- Backup everything: Take a full backup of all Site5 mailboxes via cPanel's Backup feature before starting
- Check server limits: Site5 may have IMAP connection limits—if you hit errors, add a
sleep 30line in the bash script to pause between syncs
内容的提问来源于stack exchange,提问作者Brian Francoeur

