Monthly Archives: September 2013

Migrate your IMAP account to Microsoft Office 365

What will you 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

[codesyntax lang="bash"]

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

[/codesyntax]

2. Installing required packages

[codesyntax lang="bash"]

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

[/codesyntax]

3. Checking dependencies

[codesyntax lang="bash"]

cd imapsync
perl -c imapsync

[/codesyntax]

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

imapsync syntax OK

4. Create the password files

[codesyntax lang="bash"]

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

[/codesyntax]

5. Do the migration

[codesyntax lang="bash"]

./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

[/codesyntax]

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