First, ensure that you have the correct settings for Gmail, as seen at the following link:
Port Number: 993
If you have verified that the settings are correct, then check the following Gmail or Google account settings (using a Web Browser on you computer):
1. 2-step verification is enabled. If that is the case, then you need to either disable 2-step verification, or (if you want to keep using it) use exactly the same ID/Password for both stages.
2. The setting for "Allow less secure apps" might need to be enabled. Go to Gmail or your google account and search for "Allow less secure apps" to get to this setting.