Search in sources :

Example 1 with SimpleMailConfig

use of com.outjected.email.impl.SimpleMailConfig in project simple-email by codylerum.

the class TestMailConfigs method gmailConfig.

public static SimpleMailConfig gmailConfig() {
    SimpleMailConfig mailConfig = new SimpleMailConfig();
    mailConfig.setServerHost("localhost");
    mailConfig.setServerPort(8978);
    mailConfig.setUsername("test");
    mailConfig.setPassword("test12!");
    mailConfig.setAuth(true);
    return mailConfig;
}
Also used : SimpleMailConfig(com.outjected.email.impl.SimpleMailConfig)

Example 2 with SimpleMailConfig

use of com.outjected.email.impl.SimpleMailConfig in project simple-email by codylerum.

the class TestMailConfigs method standardConfig.

public static SessionConfig standardConfig() {
    final SimpleMailConfig mailConfig = new SimpleMailConfig();
    mailConfig.setServerPort(25252);
    return mailConfig;
}
Also used : SimpleMailConfig(com.outjected.email.impl.SimpleMailConfig)

Example 3 with SimpleMailConfig

use of com.outjected.email.impl.SimpleMailConfig in project simple-email by codylerum.

the class FreeMarkerMailMessageTest method testSMTPSessionAuthentication.

@Test
public void testSMTPSessionAuthentication() throws MessagingException, IOException {
    SimpleMailConfig mailConfig = TestMailConfigs.gmailConfig();
    String subject = "HTML+Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();
    Person person = new Person(toName, toAddress);
    mailConfig.setServerHost("localHost");
    mailConfig.setServerPort(8978);
    Wiser wiser = new Wiser(mailConfig.getServerPort());
    wiser.getServer().setAuthenticationHandlerFactory(new EasyAuthenticationHandlerFactory(new SMTPAuthenticator("test", "test12!")));
    try {
        wiser.start();
        new MailMessageImpl(mailConfig).from(fromAddress).to(person.getEmail()).subject(subject).put("person", person).put("version", "Seam 3").bodyHtmlTextAlt(new FreeMarkerTemplate(Resources.asCharSource(Resources.getResource("template.html.freemarker"), Charsets.UTF_8).read()), new FreeMarkerTemplate(Resources.asCharSource(Resources.getResource("template.text.freemarker"), Charsets.UTF_8).read())).importance(MessagePriority.LOW).deliveryReceipt(fromAddress).readReceipt(fromAddress).addAttachment("template.html.freemarker", "text/html", ContentDisposition.ATTACHMENT, Resources.asByteSource(Resources.getResource("template.html.freemarker")).read()).addAttachment(new URLAttachment("http://design.jboss.org/seam/logo/final/seam_mail_85px.png", "seamLogo.png", ContentDisposition.INLINE)).send();
    } finally {
        stop(wiser);
    }
    Assert.assertTrue("Didn't receive the expected amount of messages. Expected 1 got " + wiser.getMessages().size(), wiser.getMessages().size() == 1);
    MimeMessage mess = wiser.getMessages().get(0).getMimeMessage();
    Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
    EmailMessage convertedMessage = MessageConverter.convert(mess);
    Assert.assertEquals(convertedMessage.getSubject(), subject);
}
Also used : MailMessageImpl(com.outjected.email.impl.MailMessageImpl) EmailMessage(com.outjected.email.api.EmailMessage) SMTPAuthenticator(com.outjected.email.util.SMTPAuthenticator) URLAttachment(com.outjected.email.impl.attachments.URLAttachment) Wiser(org.subethamail.wiser.Wiser) MimeMessage(javax.mail.internet.MimeMessage) SimpleMailConfig(com.outjected.email.impl.SimpleMailConfig) EasyAuthenticationHandlerFactory(org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory) FreeMarkerTemplate(com.outjected.email.impl.templating.freemarker.FreeMarkerTemplate) Test(org.junit.Test)

Aggregations

SimpleMailConfig (com.outjected.email.impl.SimpleMailConfig)3 EmailMessage (com.outjected.email.api.EmailMessage)1 MailMessageImpl (com.outjected.email.impl.MailMessageImpl)1 URLAttachment (com.outjected.email.impl.attachments.URLAttachment)1 FreeMarkerTemplate (com.outjected.email.impl.templating.freemarker.FreeMarkerTemplate)1 SMTPAuthenticator (com.outjected.email.util.SMTPAuthenticator)1 MimeMessage (javax.mail.internet.MimeMessage)1 Test (org.junit.Test)1 EasyAuthenticationHandlerFactory (org.subethamail.smtp.auth.EasyAuthenticationHandlerFactory)1 Wiser (org.subethamail.wiser.Wiser)1