Migrate your IMAP account to Microsoft Office 365

What you will do if your organization decided to move email, calendar and so on into the cloud and they choose Microsoft Office 365 and your task is to move all emails from your current server into cloud. How do you do to complete this task? First of all you search on the web (as I did) and you will find that there are some tools and documents. For me choosing a tool was the difficult part, but at the end I decided that imapsync is the best tool for this kind of tasks.

Ok, let's finish this small talk and let's get to work.

1. Get imapsync

git clone https://github.com/imapsync/imapsync

2. Installing required packages

apt-get install libmail-imapclient-perl libterm-readkey-perl

3. Checking dependencies

cd imapsync
perl -c imapsync

And if nothing is missing then you will see a message like this:

imapsync syntax OK

4. Create the password files

echo "secret_password1" > ~/secret1
echo "secret_password2" > ~/secret2
chmod 600 ~/secret1
chmod 600 ~/secret2

5. Do the migration

./imapsync --nocheckmessageexists --syncinternaldates --usecache --useuid --host1 example.com --user1 "user@example.com" --passfile ~/secret1 --ssl1 --host2 pod51011.outlook.com --user2 'user@example.com' --passfile ~/secret2 --ssl2

example.com - is the host from where you want to pull the mails
pod51011.outlook.com - is the microsoft server where you want to push the mails

Note: if you already executed the above command before then you should use --maxage n parameter so imapsync to check and pull and push only mail no more older than n days

Leave a Reply

Your email address will not be published. Required fields are marked *