Search in sources :

Example 6 with SimpleEmail

use of org.apache.commons.mail.SimpleEmail 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();
    }
}
Also used : Email(org.apache.commons.mail.Email) SimpleEmail(org.apache.commons.mail.SimpleEmail) ImageHtmlEmail(org.apache.commons.mail.ImageHtmlEmail) HtmlEmail(org.apache.commons.mail.HtmlEmail) MultiPartEmail(org.apache.commons.mail.MultiPartEmail) EmailException(org.apache.commons.mail.EmailException) DefaultAuthenticator(org.apache.commons.mail.DefaultAuthenticator) SimpleEmail(org.apache.commons.mail.SimpleEmail)

Aggregations

SimpleEmail (org.apache.commons.mail.SimpleEmail)6 Email (org.apache.commons.mail.Email)4 DefaultAuthenticator (org.apache.commons.mail.DefaultAuthenticator)3 EmailException (org.apache.commons.mail.EmailException)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 MultiPartEmail (org.apache.commons.mail.MultiPartEmail)2 Map (java.util.Map)1 EmailAttachment (org.apache.commons.mail.EmailAttachment)1 HtmlEmail (org.apache.commons.mail.HtmlEmail)1 ImageHtmlEmail (org.apache.commons.mail.ImageHtmlEmail)1 TransportConfigurationException (org.graylog2.plugin.alarms.transports.TransportConfigurationException)1 ActionDoc (org.openhab.core.scriptengine.action.ActionDoc)1