Synchronizing new mailboxes with old ones using a script

Starting from v1.6.57, it is possible to run a script after the container is started to change default settings of the onlyoffice-mail-server.

If you want to transfer mailboxes from one mail server to the ONLYOFFICE Mail Server, first you need to create the same mailboxes using the script /usr/src/iRedMail/tools/scripts/create_mailboxes.py and then perform the synchronization. To do that:

Execute the following command:

docker exec -it onlyoffice-mail-server bash

Go to the directory that contains scripts:

cd /usr/src/iRedMail/tools/scripts/

Prepare the csv file which contains a list of connection settings for new and old mailboxes and save it to the csv format, for example, imapsync_users.csv.

Below is an example of the imapsync_users.csv file:

  1. host1,user1,password1,host2,user2,password2
  2. mx1.example.com,zzz@example.com,pwd123,mx2.example.com,zzz@example.com,pwd123
  3. mx1.example.com,yyy@example.com,qwerty12,mx2.example.com,yyy@example.com,qwerty12

Where host1 (for example, mx1.example.com) - is a domain which has been specified when creating the mail server in the onlyoffice-mail-server container, and host2 - is a domain of the old mail server. Other parameters are set in the same way.

Execute the script to synchronize mailboxes:

python imapsync_batch.py imapsync_users.csv

If you want to test the script without the synchronization, you should pass the —dry parameter:

python imapsync_batch.py imapsync_users.csv dry

To find out how to perform other operations using the script, you can refer to the following articles:

Host ONLYOFFICE Workspace on your own server

Article with the tag:
Browse all tags