Email migration – Squirrelmail to Gmail/Gsuite
This manual is obsolete and soon it will be utterly useless as the less secure apps access will be disabled completely.
Even now it is better to use the –authmech2 XOAUTH2 in the json format.
Yes it is insane to set up all the prerequisites up, but once you set it up, it makes the migration bit simpler as you do not need to define the end user password.
The best explanation I found so far is in the imapsync docs https://imapsync.lamiral.info/FAQ.d/FAQ.XOAUTH2.txt
Do read all the links he mentioned how to set the json and all the needed steps on Google side, there are many.
When you have all Google ready:
imapsync –syncinternaldates –host1 old.mail.server –port1 143 –tls1 –user1 firstname.lastname@example.org –password1 secret –host2 imap.gmail.com –port2 993 –ssl2 –user2 email@example.com –password2 xyz.json –authmech2 XOAUTH2 –useheader ‘Message-Id’ –skipsize –noauthmd5 –reconnectretry1 1 –reconnectretry2 1 –justfolders –dry
If you are lucky and need to move only few email boxes use the Ape way (see bellow).
…and here follows my original, obsolete howto:
Create new website and migrate it on fresh hosting is one thing. But what about migrating emails?
Well, that is the actual hell to do.
Do you know how to do it?
You are not alone :)
The Ape way:
Once solution, is to download all emails to your computer via IMAP to Thunderbird or something like that.
Connect to the old mail (Squirrelmail or the like, create separate account) and copy all the emails and folders from the old email to Gmail one.. It will sync.
Sounds stupid. It is, but it works, sort of… The folders might not copied completely, all is saved to your disk (which might be actually good to do, but..), you can simply do mistake and move stuff instead of copy, and who knows what you actually copied or not? How will you check?
If you connect via IMAP you can drag&drop emails from one account to the other just like between folders. It takes time though in any case.
The smart way:
One line of text and one checkmark.
What you have to have is the Imapsync installed. How to do this is up to you, Google it out.
Once that is done – with Brew it is no brainer, log in to your Gmail account and lunch this link
Turn on temporarily “Access for less secure apps”. Turn it back once it’ll be all done.
Open terminal and type this:
imapsync –host1 IMAP.OLDHOST.COM –user1 ORIGINAL-EMAIL@DOMAIN.COM –password1 PASSWORD –host2 imap.gmail.com –user2 EMAIL@DOMAIN.COM –password2 GMAIL-PASSWORD –syncinternaldates –ssl1 -ssl2 –noauthmd5 –split1 100 –split2 100 –port1 993 –port2 993 –allowsizemismatch
(Change the uppercase values to match yours, obviously.)
Watch the matrix happen.
Turn back the “Access for less secure apps” to OFF.
What a relive.
The trick is to turn off the security checkbox in Google, otherwise you wont connect to Gmail no matter how correctly you specify the Imapsync call..