I was trying to use Apache Commons library to send email. But it gives me an error saying
"the type of setAuthenticator(Authenticator) is erroneous" in email.setAuthenticator function.
Here is my code. I am not sure why I get this error.
public static void sendSimpleMail() throws Exception {
Email email = new SimpleEmail();
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator("me@gmail.com","my gmail password"));
email.setDebug(false);
email.setHostName("smtp.gmail.com");
email.setFrom("me@gmail.com");
email.setSubject("Hi");
email.setMsg("This is a test mail ... :-)");
email.addTo("you@gmail.com");
email.setTLS(true);
email.send();
System.out.println("Mail sent!");
}