Sending email from google SMTP may failed some times  due to security restrictions. We may be below error. This is because account is allowed to work only with browsers not through pro-grammatically.

javax.mail.AuthenticationFailedException: 534-5.7.14 <https://accounts.google.com/signin/continue?sarp=1&scc=1&plt=AKgnsbu_
534-5.7.14 bfO8tqqRLXAkXLqsbRWLVXkVto_usUlg9qBw2H9Ez9vVEhCOt6tiGKeYNEu7qk-VQcP7Op
534-5.7.14 S_B_ZsvqoyqvO0iNMLmBBSQZJ4s7-y75zCqVIypyhyhAJlbNJRC-UOa-O3gmFxxRGa1fUL
534-5.7.14 GHkZpbWQhpr6AEocPEs-s4MF3ii__qxiJcy2QIvH4F6n_xYbK2L4g6lH_mo2Hp9ZVSbZ-V
534-5.7.14 P3cNGBFHWe2ZupWB5alKqz3ujNYWU> Please log in via your web browser and
534-5.7.14 then try again.
534-5.7.14  Learn more at
534 5.7.14  https://support.google.com/mail/answer/78754 l1sm1120215pfk.8 - gsmtp


Solution:

This can be avoided by reducing the security level of the account your using to send an email. Login to your gmail account and go to below URL and turn on less secure.

https://myaccount.google.com/lesssecureapps?pli=1

Now we will be able to send an email through google SMTP.