Moving mailboxes from one account to another on the same server

martin MHC

Well-Known Member
Sep 14, 2016
345
75
78
UK
cPanel Access Level
Root Administrator
This is a question very similar to others that I have found on these forums but have not found anything that exactly fits. Also some of the most useful answers are 7+ years old so I am wanting to receive confirnation that the way I *think* to do this, is correct.

Situation:
There are two accounts on the same WHM/cPanel server.

[email protected] has a forwarder to [email protected] which is a mailbox. I would like to stop forwarding to this second account and move the [email protected] mailbox from [email protected] in to [email protected] .

There are other (live) mailboxes on both accounts. So I can not edit anything at the account-wide level.

Both accounts are on the same server.

What Have I Tried?

I have read this but this doesn't seem to apply; although the title is exactly what I'm needing:
Move emails from one account to another on SAME server

SOLVED - Manually Copy Mail Accounts -- I have read this post but the accounts are of a size (10Gb and 4Gb) that I really want to avoid downloading and then re-uploading them again unless there is no other option.

How to move mails to another email account in same cPanel? -- This looks more like what I want but this is different mailboxes ON THE SAME ACCOUNT.

Would the solution to the last one apply even if moving mailboxes between accounts?

For example (From Tristan's Answer):

Code:
cp -R /home/account1/mail/account1.com/abc/{cur,new}/ /home/account2/mail/account1.com/abc/
Will this work? Is this the best way of doing this?
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hello @martin MHC,

The "cp -R" command you referenced should work, but it will require that you update the file ownership of the copied files after running the command. Additionally, before you take any action, it's highly advisable to create a backup of the account you are copying the emails into in-case anything goes wrong.

One of the easier workarounds I've seen reported is to simply setup the two email accounts using IMAP in a desktop email client such as Thunderbird. Then, simply create an IMAP folder under the first email account, and drap/drop all of the emails from the second email account over to the folder created under the first email account. Keep in mind this may take some time if there's a large number of emails to copy over.

Otherwise, the imapsync utility is likely the better approach via the command line:

HOW TO: Using IMAPSync to Transfer mail from server to server

Thank you.
 

martin MHC

Well-Known Member
Sep 14, 2016
345
75
78
UK
cPanel Access Level
Root Administrator
Hi @cPanelMichael , Thanks for your reply -- Yes I saw on the orginal thread the importance of taking a backup.

Also, I am aware of the download-then-upload method as per Thunderbird etc. but as stated, due to the size of the mailboxes (total 19Gb) I would like to try and avoid this method if possible.

Thank you for the link. I will look up IMAPsync.

For the purposes of completeness, if I was to do:

Code:
chown -R newuser:newgroup maildirectory
This would work with my intended method using "cp -R" above?

THanks
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,880
2,268
463
Hi @martin MHC,

Yes, the "chown" command will update the ownership values accordingly. Additionally, you can run the following command after copying over the emails for good measure:

Code:
/scripts/mailperm $username
Thank you.
 
  • Like
Reactions: martin MHC