As the security of Google's email account is gradually improved, some clients may not be able to directly create a Google account even if you have checked a lot of possible failure reasons. In fact, many applications have enabled 2-step verification function to enhance security performance, such as having to enter the code in SMS or verification code in email again then you will be able to log into its server, but for mail clients such as pbx or outlook that cannot use 2-step verification function, you might have to try Google's APP password in system email setup.
Below debug log in SSH shows authentication failure even you use correct password for your gmail id.
Below steps are shown how to enable 2-step verification and then generate APP password for gmail email id becase only have enabled 2-step verification function for your gmail id then you will be able to generate APP password.
Step1. Launch google website and click on 'Sign in' on right up corner.
Step2. Input your google account mail id then click on 'Next'.
Step3. Input password for your google account and click on 'Next'.
Step4. Click on avatar on right up corner then click on 'Google Account'.
Step5. Choose 'Security' tab then click on '2-Step Verification'.
Step6. Click on 'GET STARTED'.
Step7. Input password for your google account then click on 'Next'.
Step8. Choose your country, input your mobile phone number, choose 'Text message' then click on 'Next'. Your phone will receive one SMS with 6-digit verification code.
Step9. Input the code then click on 'Next'.
Step10. Click on 'TURN ON' to turn on 2-step verification.
Step11. Click on the left arrow '<-' to go back to google account center.
Step12. You will see 2-step verification is on then click on 'App passwords'.
Step13. Input password for google account again as per requested.
Step14. Input verification code received in SMS then click on 'Next'.
Step15. Click on 'Select device' and choose 'Other(Custom name)' in drop-down list.
Step16. Input a name for PBX, such as 'Yeastar-IPPBX' then click on 'GENERATE'.
Step17. You will see 16-character app password generated and you have to enter it in system email setup in pbx first then click on 'DONE' because you won't see the password again after clicking on 'DONE'.
Step18. Save email configurations in pbx and test again.
Step19. After testing it successfully, click on 'DONE' in step17 then you will see the device you have added and in security tab in google account you will see one app password you have generated for 'Yeastar-IPPBX' device.
Step20. If you need to set up gmail email in some more PBXS, you can follow step15 to generate more app passwords.
This article also applies to the another error code- 535 which represent the authentication failure.
Please note if you change password for gmail account, app password will be removed and system email test will be failed, so the solution is go to step 12 and regenerate app password and replace the password in system email setup in PBX.