Home  >  Forum  >  Spring
Post New Query

spring + gmail email: Authentication failed; Username and Password not accepted.


joined on
August 11,2014
Asked on February 25,2015
Hi Friends,

I am new in email API. I am trying  to send email using spring and Gmail SMTP and getting below error.

Exception in thread "main" org.springframework.mail.MailAuthenticationException: Authentication failed; nested exception is javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 px9sm24784041pbb.48 - gsmtp

at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:409)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:345)
at org.springframework.mail.javamail.JavaMailSenderImpl.send(JavaMailSenderImpl.java:340)
at com.concretepage.SendMail.main(SendMail.java:26)
Caused by: javax.mail.AuthenticationFailedException: 535-5.7.8 Username and Password not accepted. Learn more at
535 5.7.8 http://support.google.com/mail/bin/answer.py?answer=14257 px9sm24784041pbb.48 - gsmtp

at com.sun.mail.smtp.SMTPTransport$Authenticator.authenticate(SMTPTransport.java:826)
at com.sun.mail.smtp.SMTPTransport.authenticate(SMTPTransport.java:761)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:685)
at javax.mail.Service.connect(Service.java:295)
at org.springframework.mail.javamail.JavaMailSenderImpl.connectTransport(JavaMailSenderImpl.java:486)
at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:406)DEBUG SMTP: AUTH LOGIN failed

joined on
October 10,2013
Replied on February 25,2015

By default Gmail account is highly secured. When we use gmail smtp from non gmail tool, email is blocked.  To test in our local environment, make your gmail account less secure as

1. Login to Gmail. 
2. Access the URL as https://www.google.com/settings/security/lesssecureapps 
3. Select "Turn on"
joined on
March 15,2013
Replied on February 25,2015

http://www.concretepage.com/spring/spring-gmail-smtp-send-email-with-attachment-using-annotation

Write Answer









Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us