Total Pageviews

2016/04/08

[Java Mail] Caused by: javax.mail.AuthenticationFailedException: 534-5.7.9 Application-specific password required.

Problem
I am writing a mail sending function by Java Mail API, and using gmail mail server as my smtp server. But as I try to run my testing code, it throw this exception:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
Caused by: javax.mail.AuthenticationFailedException: 534-5.7.9 Application-specific password required. Learn more at
534 5.7.9  https://support.google.com/accounts/answer/185833 xn8sm19248891pab.15 - 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:501)
 at org.springframework.mail.javamail.JavaMailSenderImpl.doSend(JavaMailSenderImpl.java:421)
 ... 4 more


How-To
You can go to https://support.google.com/accounts/answer/185833 to check the root cause.
Google asks you to generate an application specific password instead of your password.


Then I can send email via gmail mail server successfully.

No comments: