I'm trying to send a simple text email using commons email
Email email = new SimpleEmail();
email.setHostName("smtp.gmail.com");
email.setSmtpPort(587);
email.setAuthenticator(new DefaultAuthenticator("[email protected]", "123456"));
email.setTLS(true);
email.setFrom(from);
email.setSubject(subject);
email.setMsg(mesage);
email.addTo("[email protected]");
email.send();
But when I try to send the email ,I get this exception:
Am I missing something?
Yes, you need the JavaMail API JAR as well (this is the javax.mail
package).
Commons Email sits on top of the JavaMail API and makes it a little less awful to use.