authentication - error while sending email in Java using Apache Commons email libs -
I was trying to use the Apache Commons library to send emails. But this tells me an error
"setAuthenticator is incorrect type of" email .setup printer function.
This is my code. I am not sure why I get this error.
sending a public static zero sendmail (exception) {email email = new SimpleEmail (); Email.setSmtpPort (587); Email.setAuthenticator (new DefaultAuthenticator ("me@gmail.com", "My Gmail password")); Email.setDebug (incorrect); Email.setHostName ("smtp.gmail.com"); Email.setFrom ("me@gmail.com"); Email.setSubject ("Hi"); Email.setMsg ("This is a test match ... :-)"); Email.addTo ("you@gmail.com"); Email.setTLS (true); Email.send (); System.out.println ("Mail Sent!"); }
You can use a different method for authentication data that receives the username and password You can try to use directly, then the authentic will be controlled internally by commons-e-mail:
email.setAuthentication ("me@gmail.com", "My Gmail password" )
Comments
Post a Comment