Search in sources :

Example 21 with JavaMailSenderImpl

use of org.springframework.mail.javamail.JavaMailSenderImpl in project netxms by netxms.

the class AppContextConfig method javaMailSender.

@Bean
public JavaMailSender javaMailSender() {
    JavaMailSenderImpl sender = new JavaMailSenderImpl();
    sender.setHost(settings.getSmtpServer());
    return sender;
}
Also used : JavaMailSenderImpl(org.springframework.mail.javamail.JavaMailSenderImpl) Bean(org.springframework.context.annotation.Bean) SchedulerFactoryBean(org.springframework.scheduling.quartz.SchedulerFactoryBean)

Example 22 with JavaMailSenderImpl

use of org.springframework.mail.javamail.JavaMailSenderImpl in project commons by craftercms.

the class EmailFactoryImplTest method createMailSender.

private JavaMailSenderImpl createMailSender() {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost("localhost");
    mailSender.setPort(25);
    mailSender.setProtocol("smtp");
    mailSender.setDefaultEncoding(ENCODING);
    return mailSender;
}
Also used : JavaMailSenderImpl(org.springframework.mail.javamail.JavaMailSenderImpl)

Example 23 with JavaMailSenderImpl

use of org.springframework.mail.javamail.JavaMailSenderImpl in project molgenis by molgenis.

the class JavaMailSenderFactoryTest method testCreateMailSenderWithSpecifiedProperties.

@Test
public void testCreateMailSenderWithSpecifiedProperties() {
    final Properties javaMailProps = new Properties();
    // specify
    javaMailProps.put("mail.debug", "true");
    // override
    javaMailProps.put("mail.smtp.starttls.enable", "false");
    when(mailSettings.getJavaMailProperties()).thenReturn(javaMailProps);
    JavaMailSenderImpl actual = javaMailSenderFactory.createMailSender(mailSettings);
    assertEquals(actual.getHost(), "host");
    assertEquals(actual.getPort(), 1234);
    assertEquals(actual.getUsername(), "username");
    assertEquals(actual.getPassword(), "password");
    assertEquals(actual.getDefaultEncoding(), "UTF-8");
    final Properties actualProperties = actual.getJavaMailProperties();
    assertEquals(actualProperties.getProperty("mail.smtp.starttls.enable"), "false");
    assertEquals(actualProperties.getProperty("mail.smtp.quitwait"), "false");
    assertEquals(actualProperties.getProperty("mail.smtp.auth"), "true");
    assertEquals(actualProperties.getProperty("mail.debug"), "true");
}
Also used : JavaMailSenderImpl(org.springframework.mail.javamail.JavaMailSenderImpl) Properties(java.util.Properties) AbstractMockitoTest(org.molgenis.test.AbstractMockitoTest) Test(org.testng.annotations.Test)

Example 24 with JavaMailSenderImpl

use of org.springframework.mail.javamail.JavaMailSenderImpl in project cloudbreak by hortonworks.

the class MailSenderConfig method mailSender.

@Bean
public JavaMailSender mailSender() {
    JavaMailSender mailSender;
    if (isMailSendingConfigured()) {
        mailSender = new JavaMailSenderImpl();
        ((JavaMailSenderImpl) mailSender).setHost(host);
        ((JavaMailSenderImpl) mailSender).setPort(port);
        if (!StringUtils.isEmpty(userName)) {
            ((JavaMailSenderImpl) mailSender).setUsername(userName);
        }
        if (!StringUtils.isEmpty(password)) {
            ((JavaMailSenderImpl) mailSender).setPassword(password);
        }
        ((JavaMailSenderImpl) mailSender).setJavaMailProperties(getJavaMailProperties());
    } else {
        mailSender = new DummyEmailSender();
    }
    return mailSender;
}
Also used : JavaMailSenderImpl(org.springframework.mail.javamail.JavaMailSenderImpl) JavaMailSender(org.springframework.mail.javamail.JavaMailSender) Bean(org.springframework.context.annotation.Bean)

Example 25 with JavaMailSenderImpl

use of org.springframework.mail.javamail.JavaMailSenderImpl in project spring-cloud-connectors by spring-cloud.

the class MailSenderCreator method create.

@Override
public JavaMailSender create(SmtpServiceInfo serviceInfo, ServiceConnectorConfig config) {
    JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
    mailSender.setHost(serviceInfo.getHost());
    mailSender.setPort(serviceInfo.getPort());
    mailSender.setUsername(serviceInfo.getUserName());
    mailSender.setPassword(serviceInfo.getPassword());
    return mailSender;
}
Also used : JavaMailSenderImpl(org.springframework.mail.javamail.JavaMailSenderImpl)

Aggregations

JavaMailSenderImpl (org.springframework.mail.javamail.JavaMailSenderImpl)56 Properties (java.util.Properties)25 Bean (org.springframework.context.annotation.Bean)14 MimeMessage (javax.mail.internet.MimeMessage)11 MessagingException (javax.mail.MessagingException)10 MimeMessageHelper (org.springframework.mail.javamail.MimeMessageHelper)10 Test (org.junit.Test)9 JavaMailSender (org.springframework.mail.javamail.JavaMailSender)6 Date (java.util.Date)4 IOException (java.io.IOException)3 ByteArrayResource (org.springframework.core.io.ByteArrayResource)3 MailException (org.springframework.mail.MailException)3 SimpleMailMessage (org.springframework.mail.SimpleMailMessage)3 GreenMail (com.icegreen.greenmail.util.GreenMail)2 BufferedReader (java.io.BufferedReader)2 InputStream (java.io.InputStream)2 InputStreamReader (java.io.InputStreamReader)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2