“We have to run as fast as possible,
just to stay in the same place” - this phrase of Lewis Carroll can be safely applied to the work of IT specialists, because trends in the information technology industry are changing faster than anywhere else. So, for example, a corporate mail server that was once implemented in an enterprise does not fully meet the demands of modern business, which in order to stay afloat requires a complete collaboration system that can easily integrate with other enterprise information systems.

IT managers who want not only to organize a working collab-system at the enterprise, but also to save the budget allocated for IT as much as possible, often pay attention to Zimbra Open-Source Edition. The advantages of Zimbra OSE include free and completely open source solution, as well as the fact that tens of thousands of companies around the world successfully use Zimbra OSE in their work. But it is not enough just to introduce the system in the enterprise; it is necessary to transfer all the accumulated correspondence from the old mail server to it.
To solve this problem, there are several commercial products with different functionality. However, there is a free way to transfer letters from the old server to Zimbra using the imapsync application. That he is officially recommended. However, despite the seeming simplicity, there are still some hidden pitfalls that IT managers may encounter when synchronizing mail.
Install imapsync is required on the source server. Transfer of correspondence is carried out by a simple console command, in which the address of the source server and the address of the server with Zimbra are indicated, as well as the username and password of the user on both mail servers.
imapsync --nosyncacls --subscribe --syncinternaldates \
--host1 mail.server.local --user1% Login% --pass1% Password% \
--host2 zimbra.server.local --user2% ZimbraLogin% --password2% ZimbraPassword%
In the event that there are too many users, you can try to automate the process by creating an imap_users file, into which you then add information about domains, user names and passwords to their accounts. For example, like this:

Now it remains only to write a simple script, give it the right to execute and run it. After running the script, the program automatically synchronizes the correspondence between the source mail server and the server with Zimbra. The final script will look like this:
. imap_users
src_srv = source.server.com
dest_srv = zimbra.server.com
for ((i = 0; i <$ {# users [@]}; i ++))
do
/ usr / bin / imapsync --noauthmd5 --syncinternaldates --buffersize 65535000 --subscribe \
-host1 $ src_srv --ssl1 --user1 $ {users [$ i]} --password1 $ {passwords [$ i]} --nofastio1
--host2 $ dest_srv --ssl2 --user2 $ {users [$ i]} --password2 $ {passwords [$ i]} --nofastio2
done
In the event that you are not going to decommission the old mail server after moving to Zimbra and a new correspondence will appear on it, you can automate the execution of this script using cron.
However, smoothly this process looks only on paper. Often, IT managers face unexpected problems. One of them is the default limit in Zimbra of 10 megabytes per email, which is why an attempt to synchronize emails with large attachments can lead to an error.
You can resolve this issue by increasing the maximum allowable letter size. For example, the command
zmprov mcf zimbraMtaMaxMessageSize 52428800 increases it to 50 megabytes.
Errors can occur when synchronizing large mailboxes with a huge number of folders and subfolders containing thousands of letters. Due to the large size of such boxes on the Zimbra server side, a disconnection may occur due to the expiration of the session time. To prevent this from happening, we recommend starting synchronization with the parameters
--nofoldersizes --skipsize --fast .