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 the 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 /usr/src/iRedMail/tools/scripts/create_mailboxes.py script 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 the scripts:

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

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

Below is an example of the imapsync_users.csv file:

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

Where host1 (for example, mx1.example.com) is the domain that was specified when creating the mail server in the onlyoffice-mail-server container, and host2 is the 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, pass the --dry parameter:

python imapsync_batch.py imapsync_users.csv --dry

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

Article with the tag:
Browse all tags