Post Date: February 07, 2019
Last Updated: October 07, 2026
Introduction
There are situations where you may need to migrate email accounts from Google Workspace (formerly G Suite) to a cPanel-based mail hosting server.
Using the imapsync tool, you can migrate existing emails from the Google Workspace IMAP server to the cPanel mail server while preserving the existing mailbox data.
In this guide, we will explain how to migrate an email account from Google Workspace to cPanel using imapsync.
Prerequisites
Before starting the migration, make sure you have the following information available.
Google Workspace Email Account
You will need the source Google Workspace email account credentials:
- Google Workspace email address
- Password or applicable authentication credentials
- IMAP access enabled
cPanel Email Account
You will also need the destination mailbox details:
- cPanel email address
- cPanel email account password
- Destination mail server hostname
Server Access
You need SSH access with sufficient privileges to install and run imapsync.
Implementation
Install imapsync
If imapsync is not already installed on the server, you can install it using:
sudo yum install imapsync
The exact installation command may vary depending on the Linux distribution and repository configuration.
Create Password Files
For better security, avoid placing email passwords directly in the imapsync command.
Create separate files for the source and destination mailbox passwords.
For example:
/etc/secret1 /etc/secret2
Store the Google Workspace mailbox password in /etc/secret1 and the cPanel mailbox password in /etc/secret2.
Make sure these files have appropriate permissions so that unauthorized users cannot access the stored credentials.
Start a Screen Session
For larger mailboxes, migration can take some time. Running the migration inside a screen session allows the process to continue even if your SSH connection is interrupted.
Start a screen session:
screen -S mail_migration
Run the Mail Migration
Use the following imapsync command:
imapsync --host1 imap.gmail.com --port1 993 --ssl1 --user1 info@domain.com --passfile1 /etc/secret1 --host2 mail.domain.com --port2 993 --ssl2 --user2 info@domain.com --passfile2 /etc/secret2
Replace the following values with your actual mailbox information:
info@domain.com— Source Google Workspace email accountmail.domain.com— cPanel mail server hostname/etc/secret1— File containing the source mailbox password/etc/secret2— File containing the destination mailbox password
Verify the Migration
Once imapsync completes, log in to the destination cPanel mailbox and verify that the required emails and folders have been migrated successfully.
For larger mailboxes, it is recommended to verify important folders such as:
- Inbox
- Sent
- Drafts
- Archive
- Custom folders
Enable IMAP Access
The source mailbox must be accessible through IMAP for imapsync to retrieve the messages.
If IMAP access is disabled or restricted, enable the required access before starting the migration.
Note: Google Workspace authentication and IMAP access requirements may vary depending on the organization’s security policies. Modern Google Workspace environments may require an appropriate authentication method rather than a basic username/password login.
Conclusion
Migrating email accounts from Google Workspace to cPanel can be performed using imapsync, provided that both the source and destination mailboxes are accessible through IMAP.
For a successful migration, verify the source and destination credentials, configure IMAP access, protect mailbox credentials, and run the migration from a persistent terminal session such as screen.
Always verify the migrated mailbox contents before decommissioning the original Google Workspace mailbox.
Frequently Asked Questions
What is imapsync?
imapsync is a mailbox migration tool that can synchronize email messages between IMAP-compatible mail servers.
Can I migrate emails from Google Workspace to cPanel?
Yes. If the Google Workspace mailbox and cPanel mailbox are accessible through IMAP, imapsync can be used to migrate the mailbox data.
Do I need IMAP access for the migration?
Yes. imapsync relies on IMAP to access and transfer mailbox messages.
Why should I use screen during migration?
Mailbox migrations can take a significant amount of time. Running the process inside a screen session helps prevent an SSH disconnection from terminating the migration process.
Where should I store the mailbox passwords?
The original example uses password files such as /etc/secret1 and /etc/secret2. These files should be protected with restrictive permissions because they contain sensitive credentials.
Will the original Google Workspace mailbox be deleted?
No. An imapsync migration copies or synchronizes mailbox data; it does not automatically delete the source mailbox. You should independently verify the destination mailbox before making any changes to the source environment.
Related Articles
- How to enable email notifications for the Nagios alerts
- HOW TO EXPORT/IMPORT EMAILS IN CPANEL WEBMAIL
Need Help with Email Migration?
Need help migrating email accounts from Google Workspace or other mail servers to cPanel? Our team can assist with mailbox migration, IMAP configuration, DNS and mail server setup, authentication, troubleshooting, and post-migration verification. Get in touch with our team here.