use of org.apache.sling.commons.messaging.mail.MailBuilder in project sling by apache.
the class SimpleMailBuilderIT method testBuildWithDefaults.
@Test
public void testBuildWithDefaults() throws Exception {
final MailBuilder mailBuilder = getService(MailBuilder.class);
final Email email = mailBuilder.build("Stop your messing around, Better think of your future...", "rudy@ghosttown", Collections.emptyMap());
email.buildMimeMessage();
final byte[] bytes = MailUtil.toByteArray(email);
final String mail = new String(bytes, StandardCharsets.UTF_8);
logger.debug("mail: " + mail);
assertEquals("rudy@ghosttown", email.getToAddresses().get(0).getAddress());
assertEquals("Rudy, A Message to You", email.getSubject());
assertEquals("dandy.livingstone@kingston.jamaica", email.getFromAddress().getAddress());
assertEquals("localhost", email.getHostName());
logger.debug(email.getMimeMessage().getContent().toString());
}
use of org.apache.sling.commons.messaging.mail.MailBuilder in project sling by apache.
the class SimpleMailBuilderIT method testBuildWithData.
@Test
public void testBuildWithData() throws Exception {
final MailBuilder mailBuilder = getService(MailBuilder.class);
final Map<String, String> configuration = new HashMap<>();
configuration.put("mail.subject", "Rudy, A Message to You");
configuration.put("mail.from", "specials@thespecials.com");
final Map data = Collections.singletonMap("mail", configuration);
final Email email = mailBuilder.build("A Message to You, Rudy", "rudy@ghosttown", data);
email.buildMimeMessage();
final byte[] bytes = MailUtil.toByteArray(email);
final String mail = new String(bytes, StandardCharsets.UTF_8);
logger.debug("mail: " + mail);
assertEquals("rudy@ghosttown", email.getToAddresses().get(0).getAddress());
assertEquals("Rudy, A Message to You", email.getSubject());
assertEquals("specials@thespecials.com", email.getFromAddress().getAddress());
assertEquals("localhost", email.getHostName());
logger.debug(email.getMimeMessage().getContent().toString());
}
Aggregations