public static EMLComposer create() { return new EMLComposer(); }
/** * Creates EML string from given {@link Email}. * * @param email {@link Email} from which to create EML {@link String}. * @return {@link String} with EML content. */ public String compose(final Email email) { if (getSession() == null) { createSession(getProperties()); } final OutputStreamTransport ost = new OutputStreamTransport(getSession()); final SendMailSession sendMailSession = new SendMailSession(getSession(), ost); sendMailSession.sendMail(email); return ost.getEml(); }
@Test void testWriteSimpleReceivedEmail() throws FileNotFoundException, MessagingException { final URL data = EMLComposerTest.class.getResource("test"); final File emlFile = new File(data.getFile(), "simple.eml"); ReceivedEmail email = EMLParser.create().parse(emlFile); final String eml = EMLComposer.create().compose(email); assertTrue(eml.contains("From: sender@emailhost.com\r\n")); assertTrue(eml.contains("To: recipient@emailhost.com\r\n")); } }
@Test void testWriteSimpleEmail() { final Email email = Email.create().from("Joe@example.com").to("Pig@example.com").textMessage(HELLO); final String eml = EMLComposer.create().compose(email); assertTrue(eml.contains("From: Joe@example.com\r\n")); assertTrue(eml.contains("To: Pig@example.com\r\n")); assertTrue(eml.contains(HELLO)); }
/** * Creates EML string from given {@link Email}. * * @param email {@link Email} from which to create EML {@link String}. * @return {@link String} with EML content. */ public String compose(final Email email) { if (getSession() == null) { createSession(getProperties()); } final OutputStreamTransport ost = new OutputStreamTransport(getSession()); final SendMailSession sendMailSession = new SendMailSession(getSession(), ost); sendMailSession.sendMail(email); return ost.getEml(); }
public static EMLComposer create() { return new EMLComposer(); }