Generate App Password for Gmail Inbox
Note: This is for those gmail accounts where 2-step verification is enabled or which are managed by an organization.
Step 1. Go to Google Account Security.
Step 2. Click "App passwords" under "Signing in to Google" section in the security page.
Step 3. Select Mail app, select a device and click "GENERATE". Use the generated password to configure IMAP/SMTP.