Search in sources :

Example 16 with DefaultAuthenticator

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();
    }
}
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

DefaultAuthenticator (org.apache.commons.mail.DefaultAuthenticator)16 Email (org.apache.commons.mail.Email)7 EmailException (org.apache.commons.mail.EmailException)6 HtmlEmail (org.apache.commons.mail.HtmlEmail)6 SimpleEmail (org.apache.commons.mail.SimpleEmail)4 URL (java.net.URL)3 EmailAttachment (org.apache.commons.mail.EmailAttachment)3 ImageHtmlEmail (org.apache.commons.mail.ImageHtmlEmail)3 MultiPartEmail (org.apache.commons.mail.MultiPartEmail)3 Properties (java.util.Properties)2 MalformedURLException (java.net.MalformedURLException)1 FXML (javafx.fxml.FXML)1 DataSource (javax.activation.DataSource)1 Authenticator (javax.mail.Authenticator)1 Session (javax.mail.Session)1 Transport (javax.mail.Transport)1 DataSourceClassPathResolver (org.apache.commons.mail.resolver.DataSourceClassPathResolver)1 DataSourceUrlResolver (org.apache.commons.mail.resolver.DataSourceUrlResolver)1 Programmatic (org.apache.isis.applib.annotation.Programmatic)1 ActionDoc (org.openhab.core.scriptengine.action.ActionDoc)1