How to move or restore cPanel emails and accounts to another folder or server
All cPanel email will be stored in a folder similar to this:
/home/user/mail/domain
If you remove an addon domain from a cpanel account, the email will still be left on the server (as well as ftp, etc). This is good and bad, i think more on the good side. If you need to move any email from one account to another you can do so through ssh
1 |
cp -rf /home/olduser/mail/ /home/newuser/ |
This will copy all the files from the /home/olduser/mail/ directory, including the directory itself to the /home/newuser/ folder. This means any addon domains, all those emails are included. If you only want a specific domain you can copy that folder and follow the same steps below. -r is recursively so it copies all files and folders. -f is force so it overwrites any files that may already be there.
Now that you have moved the emails over we need to set the permissions on that folder since it now has a new owner and group.
1 |
chown -R newuser:newuser /home/newuser/mail |
This will change ownership of the folder to the new users account it is actually under. -R is recursively so it changes it for all files and folders. Must be a capital R.
That’s all there is to it, cPanel will automatically load all the email accounts.
Easy right?
Emails still not showing up? Make SURE you CHOWN the directories to the correct user!