Importing Email Accounts


Sep 23, 2010
I would like to find a way to create email accounts via SSH.
More specifically, I get clients who want to import email accounts an their messages from one cPanel server to another. Usually this isn't possible without using a CPmove file and the restorepkg script. Is there a way to do that only using ssh?


Well-Known Member
Feb 25, 2010
Houston, TX
cPanel Access Level
Root Administrator
cPanel e-mail accounts have their username, password and quota information stored in files in the following directory format:



  • $HOME = the home directory;
  • $USER = the cPanel account user, and;
  • $DOMAIN = the domain for the e-mail account.

Within that directory, passwd, shadow and quota are the files that need to be copied over. All three files are in plain ASCII text format, so you can copy and paste entries from them if needed. There will also be a ",v" file for each file. This is an RCS revision log, and it does not necessarily need to be copied.

The mail data themselves are stored in the following directory structure:



  • $HOME = the home directory;
  • $USER = the cPanel account user;
  • $DOMAIN = the domain for the e-mail account, and;
  • $EMAILUSER = the username portion of the e-mail address.

$EMAILUSER is a directory, and it contains all of the mail for that particular mailbox within its subdirectories. Messages that have not been read yet are in the new subdirectory, and messages that have been read are in the cur subdirectory. There are additional subdirectories for IMAP folders that have been created. Each mail message is stored in a single text file.

If you copy e-mail accounts manually to another server, you will want to move /$HOME/$USER/.cpanel/email_accounts.yaml and /$HOME/$USER/.cpanel/email_accounts.cache so that they will be regenerated the next time you log into cPanel as the account user. Moving the files will force cPanel to re-read the passwd and shadow file for the account and correctly populate the email_accounts.yaml file.