Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Moving mailboxes from one account to another on the same server

Discussion in 'E-mail Discussion' started by martin MHC, Feb 7, 2019.

  1. martin MHC

    martin MHC Well-Known Member

    Joined:
    Sep 14, 2016
    Messages:
    141
    Likes Received:
    21
    Trophy Points:
    18
    Location:
    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.

    abc@account1.com has a forwarder to abc@account2.com which is a mailbox. I would like to stop forwarding to this second account and move the abc@account2.com mailbox from abc@account2.com in to abc@account1.com .

    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?
     
  2. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,009
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. martin MHC

    martin MHC Well-Known Member

    Joined:
    Sep 14, 2016
    Messages:
    141
    Likes Received:
    21
    Trophy Points:
    18
    Location:
    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
     
  4. cPanelMichael

    cPanelMichael Technical Support Community Manager Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    47,009
    Likes Received:
    2,123
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Twitter:
    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.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
    martin MHC likes this.
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice