If you’ve switched hosting and need to migrate one or more email accounts from another server to your cPanel account, you can use our script.
This script allows you to transfer one or more IMAP email accounts from an external server to one or more email accounts on cPanel.
This way, you won’t need to perform the email transfer manually; instead, you can use the script to automate the process.
To proceed, you’ll need the IMAP server address, as well as the email addresses and passwords for the accounts you wish to transfer.
The script works automatically: if the email boxes haven’t been created, the script will create them for you. You can only migrate the email boxes of the domains associated with your cPanel account.
You can migrate a single email box or multiple email boxes simultaneously.
How to transfer an email box
Here’s how to proceed if you need to transfer a single email account. If you need to transfer multiple accounts, follow the instructions in the next section.
Open the terminal from cPanel.
Type:
syncmail.sh
You’ll be shown a brief guide on how to use the script.
To migrate a single email box, type:
syncmail.sh [email protected]
Replace “[email protected]” with the email account you want to migrate.
You’ll be prompted for the address of the IMAP server where the email account is hosted. (To use the default address, just press Enter.)
Next, enter the password for the email account you want to import and press Enter to start the import.
Upon completion of the import, we are given a summary with the amount of transferred emails and any emails with errors.
How to transfer multiple email accounts
To migrate multiple email accounts in one command, you’ll need to create a CSV file containing the email addresses and passwords of the accounts you want to transfer.
Create a CSV file in the following format:
[email protected];password1
[email protected];password2
[email protected];password3
[email protected];password4
You can create this CSV file directly from the file manager.
Or use a program like Windows Notepad and then upload it to the server.
If you have multiple email accounts with different domains, it’s best to create separate CSV files for each domain.
For example, if you have two @domain1.com email accounts and two @other-domain.com email accounts, create two separate CSV files like this:
CSV file 1:
[email protected];password1
[email protected];password2
CSV file 2:
[email protected];password1
[email protected];password2
After creating the file(s), open the terminal from cPanel and type:
syncmail.sh email.csv
Where “email.csv” is the name of the file you created.
Note: If the file is not uploaded to the root directory, you’ll need to specify the file path.
You’ll then be prompted to enter the address of the IMAP server where the email accounts are hosted. To use the default address, just press Enter.
A list of email accounts to be migrated will be displayed. To confirm, type “y”.
Frequently asked questions
Can I synchronize multiple times?
Yes, if you run the syncmail.sh command multiple times, the emails will be resynchronized.
What should I do if the email transfer fails?
If the email transfer fails, first check that the correct password has been entered.
If the issue persists, try changing the email password to use only letters and numbers, avoiding special characters.