Email migration – Squirrelmail to Gmail

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?
No?
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?

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
https://www.google.com/settings/u/1/security/lesssecureapps
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.

Sources:
https://github.com/imapsync/imapsync
http://oskarhane.com/transfer-e-mail-from-gmail-to-another-imap-server/
https://imapsync.lamiral.info/FAQ.d/FAQ.Gmail.txt

note:
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..