This was considerably harder than I thought and there is very little online about migrating away from Office 365 to cPanel. This guide makes things much simpler, saving time looking up the relevant arguments and avoiding the mismatches with the names of the main IMAP folders. You’ll need a copy of the free software: IMAPSync – used to synchronise emails to and from one server to another.
One of the issues with migrating away from Outlook with Office 365 is the slightly different folder names in use compared to IMAP in cPanel (and likely elsewhere). The arguments listed with IMAP Sync will rename these to the more common IMAP folder names.
If you use a firewall, make sure that you have an outgoing firewall exception for port 993 so that you can make the connection. Initially I didn’t spot this, very annoying!
Just want to run this for one account?
imapsync --host1 outlook.office365.com \ --ssl1 \ --timeout1 15 \ --user1 rs_wpss_encode_stralias@somedomain.com \ --password1 aPasswordGoesHere123zzz \ --host2 destination.server.com \ --timeout2 15 \ --ssl2 \ --user2 rs_wpss_encode_stralias@somedomain.com \ --password2 somePASSWORD123xxABC \ --maxsize 200000000 \ --maxlinelength 10500 \ --maxmessagespersecond 20 \ --regexflag 's/\\Flagged//g' \ --disarmreadreceipts \ --exclude "Calendar" \ --exclude "Contacts" \ --regextrans2 "s/Sent.*/Sent/" \ --regextrans2 "s/(Junk|spam).*/Junk/" \ --regextrans2 "s/(Trash|Delete).*/Trash/";
Or you can set a CRON Job to synchronise accounts at regular intervals or just use nohup to run the task in the background (if there are lots of emails):
#! /bin/bash declare -a users=("anne" "bill" "catherine" "digby") for username in "${users[@]}" do /usr/bin/imapsync --host1 outlook.office365.com \ --ssl1 \ --timeout1 15 \ --user1 rs_wpss_encode_str$username@somedomain.com \ --password1 aPasswordGoesHere123zzz \ --host2 destination.server.com \ --timeout2 15 \ --ssl2 \ --user2 rs_wpss_encode_str$username@somedomain.com \ --password2 somePASSWORD123xxABC \ --maxsize 200000000 \ --maxlinelength 10500 \ --maxmessagespersecond 20 \ --regexflag 's/\\Flagged//g' \ --disarmreadreceipts \ --exclude "Calendar" \ --exclude "Contacts" \ --regextrans2 "s/Sent.*/Sent/" \ --regextrans2 "s/(Junk|spam).*/Junk/" \ --regextrans2 "s/(Trash|Delete).*/Trash/"; done;
Some tips
- For the purpose of the transfer, use a more straight-forward password and I’ve set all the accounts to use same password while the synchronisation is live;
- Check all the emails have made it across with Webmail as the synchronisation goes through – you can press Ctrl C in Shell to escape.
- IMAPSync can be really, really slow, so use nohup to run it in the background (easier than CRON) and you can view the output in a log file.
Please let me know if you see anything that I can improve upon here.
Updated: 15th January 2018…
Yahoo! Mail
I’ve synchronised a Yahoo! Mail account today using the following settings:
imapsync --host1 imap.mail.yahoo.com \ --ssl1 \ --timeout1 15 \ --user1 rs_wpss_encode_stralias@somedomain.com \ --password1 aPasswordGoesHere123zzz \ --host2 destination.server.com \ --timeout2 15 \ --ssl2 \ --user2 rs_wpss_encode_stralias@somedomain.com \ --password2 somePASSWORD123xxABC \ --syncinternaldates \ --noauthmd5 \ --split1 100 \ --split2 100 \ --port1 993 \ --port2 993 \ --noabletosearch;
You’ll need to disable Two-step verification and create a specific password for the transfer located in: Manage app passwords.
Updated: 5th May 2018…
Hushmail
For Hushmail, just use the same arguments as Yahoo! Mail with this added:
--addheader
Use nohup to run in the background
If you’d like to start the process and leave it running as a separate task, you can use nohup, place the script into a file (e.g. imap_sync_command.sh) and save the output to a text file…
nohup imap_sync_command.sh &> imap_sync.log &
Last updated on