Move mailboxes between IMAP servers with IMAPcopy

IMAPCopy allows you to recursively copy all email messages and folders from another IMAP account. It supports IMAP and IMAPS protocols. In this article we will guide you to move mailboxes between IMAP servers using IMAPcopy.

TipsMake.com - IMAPCopy allows you to recursively copy all email messages and folders from another IMAP account. It supports IMAP and IMAPS protocols. In this article we will guide you to move mailboxes between IMAP servers using IMAPcopy.

Some notes when using the program:

  1. IMAPcopy only has a copy function, does not delete mail in the source mailbox.
  2. To use the program, you must activate the IMAP protocol in both the source mailbox and the destination mailbox.
  3. You can only copy mail in INBOX , not copy in SENT , DELETED , TRASH . If you use mail client program (MS Outlook, Mozilla Thunderbird, .) to trade mail, when copying mail via mailbox new, the mail client will have to download the whole mail.

In the following illustration we use two Debian or Ubuntu servers. For other distributions, the process is similar, except that the difference between Java and IMAPcopy is different.

Source server: server1.example.com .
Destination server: server2.example.com .

Our purpose is to move the mailbox sales@example.com (username: sales@example.com , password: secret ) on Server1.example.com to the sales@example.com mailbox on server2.example.com ( The username and password are the same as on server1.example.com ).

In addition, Ubuntu users should note that the following command must be run as root , so either add the sudo string after each command line or become root with the command:

sudosu

Prepare

Before we get started, let's check both mailboxes to see what's in it (you can do this by any email client service like Outlook, Thunderbird or web mail like SquirrelMail we use below.) here).

server1.example.com:

Picture 1 of Move mailboxes between IMAP servers with IMAPcopy

server2.example.com:

Picture 2 of Move mailboxes between IMAP servers with IMAPcopy

After doing the following, the three messages in server1.example.com will appear in server2.example.com .

IMAPcopy settings

It is not important to install IMAPcopy on server1.example.com or server2.example.com , you can even install it on a 3rd machine without any trouble.

However, installing Java is necessary with IMAPcopy, so we will install the openjdk-6-jre package. In addition, make sure that the unzip is installed in order to extract the IMAPcopy package.

apt-get installopenjdk-6-jre unzip

Next download and install IMAPcopy in the path / usr / local / imapcopy / as below:

cd / usr / local /
mkdir imapcopy
cd imapcopy
wget http://imapcopy.googlecode.com/files/imapCopy0.3.1.zip
unzip imapCopy0.3.1.zip

Execute the script /usr/local/imapcopy/imapCopy.sh :

chmod + x /usr/local/imapcopy/imapCopy.sh

Proceed to move the mailbox

After successful installation, you start using IMAPcopy as follows:

/usr/local/imapcopy/imapCopy.sh protocol: // user [: password] @server [: port] protocol: // user [: password] @server [: port]

This protocol can use IMAP or IMAPS. If the username is the email address to note, replace @ with % 40 . Finally the command line to copy email messages from sales@example.com on erver1.example.com to sales@example.com on server2.example.com will be:

/usr/local/imapcopy/imapCopy.sh imap: //sales%40example.com: secret@server1.example.com imap: //sales%40example.com: secret@server2.example.com

And here is an example of output:

root @ server1: / usr / local / imapcopy # /usr/local/imapcopy/imapCopy.sh imap: //sales%40example.com: secret@server1.example.com imap: //sales%40example.com: secret @ server2.example.com
2011-09-30 13:28: 27,751 INFO ImapCopier - Starting
2011-09-30 13:28: 27,751 DEBUG ImapCopier - Parameters length: 2
2011-09-30 13:28: 27,751 DEBUG ImapCopier - opening conections
2011-09-30 13:28: 27,751 DEBUG ImapCopier - opening of the conection imap server1.example.com
2011-09-30 13:28: 28,737 DEBUG ImapCopier - opening conection to imap server2.example.com
2011-09-30 13:28: 28,998 DEBUG ImapCopier - Creating target Folder: Drafts
2011-09-30 13:28: 29,030 DEBUG ImapCopier - Copying 0 messages from Drafts Folder
2011-09-30 13:28: 29,033 DEBUG ImapCopier - Creating target Folder: Junk
2011-09-30 13:28: 29,058 DEBUG ImapCopier - Copying 0 messages from Junk Folder
2011-09-30 13:28: 29,059 DEBUG ImapCopier - Creating target Folder: Trash
2011-09-30 13:28: 29,061 DEBUG ImapCopier - Copying 0 messages from Trash Folder
2011-09-30 13:28: 29,061 DEBUG ImapCopier - Creating target Folder: Sent
2011-09-30 13:28: 29,120 DEBUG ImapCopier - Copying 0 messages from Sent Folder
2011-09-30 13:28: 29,527 DEBUG ImapCopier - Copying 3 messages from INBOX Folder
root @ server1: / usr / local / imapcopy #

Now on the destination server ( server2.example.com ) will see the email from server1.example.com :

Picture 3 of Move mailboxes between IMAP servers with IMAPcopy

Update 26 May 2019
Category

System

Mac OS X

Hardware

Game

Tech info

Technology

Science

Life

Application

Electric

Program

Mobile