Check that Imap is enabled in Gmail
Open Gmail via the web browser
Click on the “Cog” icon in the top right corner.
Then click Settings on the menu .
Click the Forwarding and POP/IMAP tab.
In the “IMAP access” section, select Enable IMAP.
Click Save Changes.