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("user@gmail.com", "123456"));
email.setTLS(true);
email.setFrom(from);
email.setSubject(subject);
email.setMsg(mesage);
email.addTo("to@gmail.com");
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.