This error is displayed when you have not enabled the option to allow external applications to access your Gmail account, under Sign in & security in Gmail .
To resolve this error
1. Open your Gmail account.
2. Select Accounts in Google Apps .
3. Click Sign-in & Security .
4. Ensure the 2-Step Verification is turned OFF .
5. Scroll down to enable the option Allow less secure apps .
Now, you can access your Gmail account.