I need to connect to a Microsoft Exchange Server through IMAPS JavaMail. First, I got the:
A1 NO AUTHENTICATE failed.
javax.mail.AuthenticationFailedExcepti
Try using your own Authenticator
public class ExchangeAuthenticator extends Authenticator {
String username;
String password;
public ExchangeAuthenticator(String username, String password) {
super();
this.username= username;
this.password= password;
}
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(username, password);
}
}
and in your code add
session = Session.getInstance(props,new ExchangeAuthenticator(username, password));