Site icon EcomPlugins Blog

How to sync emails between two cPanel email accounts using the command line with imapsync

To sync emails between two cPanel email accounts using the command line with imapsync, you’ll need to follow these steps. imapsync is a tool that allows you to transfer emails from one IMAP server to another. It’s useful when migrating email accounts or backing up emails.

Step 1: Install imapsync

If imapsync is not already installed on your server, you need to install it. Here’s how you can do it:

On CentOS or RedHat:

sudo yum install epel-release -y
sudo yum install imapsync -y

On Ubuntu or Debian:

sudo apt-get update
sudo apt-get install imapsync -y

Alternatively, you can download and install the latest version from the official site.

Step 2: Prepare for Synchronization

You’ll need the following information for both the source and destination cPanel email accounts:

Step 3: Run imapsync

Use the following command to sync emails between the two accounts:

imapsync --host1 source-imap-server.com --user1 source@example.com --password1 sourcepassword \
         --host2 destination-imap-server.com --user2 destination@example.com --password2 destinationpassword \
         --ssl1 --ssl2

Explanation of Options:

Example:

If your source email is source@example.com on mail.source.com and the destination is destination@example.com on mail.destination.com, the command would look like this:

imapsync --host1 mail.source.com --user1 source@example.com --password1 sourcepassword \
         --host2 mail.destination.com --user2 destination@example.com --password2 destinationpassword \
         --ssl1 --ssl2

Step 4: Additional Options

Step 5: Run the Command

Once you’ve configured the command with your specific details, execute it in your terminal. The emails should begin to sync from the source to the destination account.

Step 6: Verify

After the sync is complete, verify that the emails have been correctly transferred to the destination account.

Exit mobile version