i’m trying an example of javamail and i get the following error:
Exception in thread "main" javax.mail.AuthenticationFailedException: [AUTH] Application-specific password required: http://www.google.com/support/accounts/bin/answer.py?answer=185833
at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:208)
at javax.mail.Service.connect(Service.java:317)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Session.getFolder(Session.java:612)
at MainClass.main(MainClass.java:19)
Java Result: 1
The code used is from Java2s.com Get Attachment File Name.
And i use mail.jar from 1.4.4 version.
I don’t understand the end of the code
here:
class MailAuthenticator extends Authenticator {
public MailAuthenticator() {
}
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("username", "password");
}
}
Thank you
The account in question is set-up for two-step authentication in Google. (See here). You cannot authenticate with a simple username and password combination.
You will need to follow the instructions (the link is right within the error message itself, which is nice) to set-up an application-specific password (e.g., revert to normal one-step authentication for Google Mail) for that specific account.