Migrating emails from one server to another without Server access

Imapcopy:

There are many tools available for this mail to mail migration, here we are going to use “Imapcopy”, which I believe to be the best and easy command line tool. It does support both Imap and Imaps protocols.
Since this tool only uses ‘imap’ protocol to copy emails, not much of server resources will be used and also you do not need the admin/root login details of the server.

Requirements:

  • Login details of email accounts from both source server and destination server
  • Both servers hostnames and working imap port number (Be default it is 143 for http and 993 for https)
  • A linux machine, either a server or local machine with internet connectivity.

Procedure to install Imapcopy:

We need to install imapcopy in the linux machine, since there is no default repo available, we need to use wget to download the setup zip/tar file and install in manually. I have below pasted the steps to download and install imapcopy from a currently working repository.

  • Downloading imapcopy binary from know repository

 http://home.arcor.de/armin.diehl/imapcopy/imapcopy.tar.gz

  • Extract the downloaded .tar file

tar -xvf imapcopy.tar.gz

  • Enter the extracted directory and create a copy of the existing conf file for future use.

cd imapcopy
cp -arp ImapCopy.cfg ImapCopy.cfg_back

Note: 
We can install this imapcopy tool  in ‘exe’ version and use it in windows based machine too.  You just need to download the respective version.

The URL for Windows version :

http://home.arcor.de/armin.diehl/imapcopy/IMAPCopy.zip

Steps to proceed with migration:

Go to imapcopy directory and open the configuration file in any known text editor and update the source and destination server hostname and port number details.
Under the user section, just add the old server and new server email account login details respectively.

If you wish to skip any unnecessary folders, you can skip the same in “skipfolder” section. You just need to add the folder name in the configuration file.
For example, if you wish to skip ‘Sent’ folder, you just need to add ‘INBOX.Sent’ directory in the skipfolder section.

Once you edited the configuration with all the necessary details, you are good to go. You just need to execute the binary file which you have downloaded.

  • If you wish to test the connection before copying, you can use the ‘-t ’ option. This will check the login details updated in the “imapcopy.cfg” and paste the status.

./imapcopy -t

  • If you get no errors in the login, you can now simply run the imapcopy binary to proceed the migration.

./imapcopy

At the end of the migration, Imapcopy will show all the details about the total number of folders/emails copied to the server.

You can now save this configuration to use it for this domain again in future. If you wish to proceed with a different domains, you just need to edit the configuration.

You can copy multiple accounts in a single run, you just need to enter the respective account login details in the imapcopy configuration file.

Written by actsupp-r0cks