use of org.apache.commons.mail.DefaultAuthenticator in project SpringStepByStep by JavaProgrammerLB.
the class JavaMailDemo method sendSimpleTextMail.
// @Test
public void sendSimpleTextMail() {
try {
Email email = new SimpleEmail();
email.setHostName("smtp.googlemail.com");
email.setSmtpPort(465);
email.setAuthenticator(new DefaultAuthenticator("username", "password"));
email.setSSLOnConnect(true);
email.setFrom("username");
email.setSubject("TestMail");
email.setMsg("This is a test mail ... :-)");
email.addTo("foo@bar.com");
email.send();
} catch (EmailException e) {
e.printStackTrace();
}
}
Aggregations