Bulk move email from one user/domain to a different user/different domain

6 posts / 0 new
Last post
#1 Mon, 09/04/2017 - 04:16
sebholmes

Bulk move email from one user/domain to a different user/different domain

Hi,

I have a customer who has sold his domain. Only the email for the domain is hosted in Virtualmin (for historical reasons). He has an awful lot of personal email in the system. The new owners want me to transfer the domain over to them, understandably, but the customer wants me to transfer out all his 'old' email into a different username/domain.

I need to do this for three users and several thousand emails, so I'm desperately hoping that there's a way to bulk move/copy/transfer email!

All hints most gratefully accepted!

Mon, 09/04/2017 - 05:40
noisemarine

The user can probably do this themselves to some extent. If they are using IMAP, they can just drag all the email from one account into another.

Edit to add: in case it wasn't clear, they do that within their email client. Have both accounts setup, then drag from one to the other.

Mon, 09/04/2017 - 06:32 (Reply to #2)
sebholmes

Sadly they're on POP3 and the thought of converting/upgrading them to IMAP, given that they are complete and utter technophobes, fills me with dread! Sorry - should have made that clear in the original post. Hopefully there's another way, but if not, I guess that's what we'll have to do.

Tue, 09/05/2017 - 00:54
Joe
Joe's picture

Mail is just a directory with files in it (by default, Virtualmin uses Maildir format, partly because it is so easy to work with). You can copy it using normal tools (cp or rsync or whatever you like). No reason to make it complicated.

So, create your new user, and copy their Maildir folder into the new user's home directory with:

# cp -a /home/domain/homes/olduser/Maildir/* /home/domain/homes/newuser/Maildir/

chown it to the new username recursively, or you may need to use find with -exec chown in order to deal with the large number of files. e.g:

# cd /home/domain/homes/newuser/Maildir
# find . -exec chown newuser:newuser

Test. You're done!

Oh, dovecot indexes may need to be removed. I don't know what all information gets cached there...if it's all relative paths, it'll be fine to leave them, but if it's not it might confuse the mail client.

I've copied mailboxes hundreds of times in my life. It's not a thing to worry about, and your clients don't need to be involved in the process. All they need to do is change the server information in their mail client when the move is done.

Edit: If the cp above fails, you'll maybe have to use find -exec instead. Using find can workaround the "too many files" problem. rsync can too.

--

Check out the forum guidelines!

Tue, 09/05/2017 - 07:58
sebholmes

Looks perfect Joe. Thank you very much. I will report back for the benefit of other users in the future.

Wed, 09/06/2017 - 04:52 (Reply to #5)
Joe
Joe's picture

Oh, you may need to create the Maildir directory for the new user; I don't think it's part of the skel, but rather is created the first time mail is delivered (I think).

--

Check out the forum guidelines!

Topic locked