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("[email protected]","my gmail password"));
email.setDebug(false);
email.setHostName("smtp.gmail.com");
email.setFrom("[email protected]");
email.setSubject("Hi");
email.setMsg("This is a test mail ... :-)");
email.addTo("[email protected]");
email.setTLS(true);
email.send();
System.out.println("Mail sent!");
}