How to Enable IMAP Settings ?
-
On your computer, open Gmail.
-
In the top right, click Settings ⚙️ » See all settings.

-
Click the Forwarding and POP/IMAP tab.

-
In the "IMAP access" section, select Enable IMAP.

-
Click Save Changes.

How to Generate App Specific Password ?
First of all, Turn on 2-Step-Verification.
-
Go to your Google Account.
-
Select Security.

-
Under "How you sign in to Google," make sure 2-Step Verification is ON.
If its Off then go to https://myaccount.google.com/security and follow the on-screen steps to make it ON.
-
Then go to, Google App Password https://myaccount.google.com/apppasswords page and enter the app name » then click on Create.

-
The App Password is the 16-character code. Copy it and save it for use.

-
Tap Done.