How to change email username

democreations

Member
May 31, 2008
8
0
51
Ok I searched it and I couldnt find it.. hmm
How can I change some email account username ??

(I need to keep current emails in the inbox, I know I can just delete and create another one, but I need to change the username from one to another)
Is this possible trough cpanel ?
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
23
143
Houston, TX
cPanel Access Level
Root Administrator
Create new mailbox, then copy the mail

Since you want to save the existing messages, the easiest way to do this is to create a new account with the desired username using cPanel, copy the mail between the accounts using the shell, and then delete the old account using cPanel.

Mail on a cPanel server is stored in the following format:

/$HOME/$USER/mail/$DOMAIN/$MAILBOX

where:

$HOME = the account's home directory;
$USER = the account's cPanel username;
$DOMAIN = the domain assigned to the account, and;
$MAILBOX = the actual e-mail address defined in the account's cPanel.

Mail is stored in two directories within this directory, new and cur. new is for mail that has not yet been read, and cur is for mail that has already been read at least once.

So if you have an e-mail address, [email protected], and you want to change its name to [email protected], you can create the new address, [email protected] in cPanel, then, from the shell, copy the mail using these commands:

Code:
# cp -Rp /home/mytestdo/mail/mytestdomain.com/box1/cur/* /home/mytestdo/mail/mytestdomain.com/newbox/cur/
# cp -Rp /home/mytestdo/mail/mytestdomain.com/box1/new/* /home/mytestdo/mail/mytestdomain.com/newbox/new/
# /scripts/mailperm
This assumes that the account for mytestdomain.com is mytestdo, and that its home directory is /home. Also, while the -p switch to the cp command specifies that permissions and ownerships be preserved, it is a good idea to run mailperm after manipulating mail-related files.