Apple Mail freezes or crashes during IMAP sync with gmail
check this link - gmail changed their authentication method without notice, so you have to make this change.  You will get a confirmation email from gmail that seems scary - but it isn't.  You haven't just opened your email to the world as they try to scare you to believe.  Unfortunately, as usual, they don't work in concert with major software developers and we are left to pick-up the pieces as best we can.

https://productforums.google.com/forum/#!topic/gmail/lCjm9oim5Vo