use of com.outjected.email.impl.MailMessageImpl in project simple-email by codylerum.
the class InternetAddressTest method invalidDeliveryReceipt.
@Test(expected = InvalidAddressException.class)
public void invalidDeliveryReceipt() {
MailMessage m = new MailMessageImpl(TestMailConfigs.standardConfig());
m.deliveryReceipt("woo foo @bar.com");
}
use of com.outjected.email.impl.MailMessageImpl in project simple-email by codylerum.
the class InternetAddressTest method invalidToSimpleAddresses.
@Test(expected = InvalidAddressException.class)
public void invalidToSimpleAddresses() {
MailMessage m = new MailMessageImpl(TestMailConfigs.standardConfig());
m.to("woo foo @bar.com");
}
use of com.outjected.email.impl.MailMessageImpl in project simple-email by codylerum.
the class InternetAddressTest method invalidBccSimpleAddresses.
@Test(expected = InvalidAddressException.class)
public void invalidBccSimpleAddresses() {
MailMessage m = new MailMessageImpl(TestMailConfigs.standardConfig());
m.bcc("woo foo @bar.com");
}
use of com.outjected.email.impl.MailMessageImpl in project simple-email by codylerum.
the class MailMessageTest method testTextMailMessageUsingPerson.
@Test
public void testTextMailMessageUsingPerson() throws MessagingException, IOException {
SessionConfig mailConfig = TestMailConfigs.standardConfig();
String subject = "Text Message from Seam Mail - " + java.util.UUID.randomUUID().toString();
Person person = new Person(toName, toAddress);
String messageId = "1234@seam.test.com";
EmailMessage e;
Wiser wiser = new Wiser(mailConfig.getServerPort());
wiser.setHostname(mailConfig.getServerHost());
try {
wiser.start();
e = new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).replyTo(replyToAddress).to(person).subject(subject).bodyText(textBody).importance(MessagePriority.HIGH).messageId(messageId).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(MailTestUtil.getAddressHeader(fromName, fromAddress), mess.getHeader("From", null));
Assert.assertEquals(MailTestUtil.getAddressHeader(replyToAddress), mess.getHeader("Reply-To", null));
Assert.assertEquals(MailTestUtil.getAddressHeader(toName, toAddress), mess.getHeader("To", null));
Assert.assertEquals("Subject has been modified", subject, MimeUtility.unfold(mess.getHeader("Subject", null)));
Assert.assertEquals(MessagePriority.HIGH.getPriority(), mess.getHeader("Priority", null));
Assert.assertEquals(MessagePriority.HIGH.getX_priority(), mess.getHeader("X-Priority", null));
Assert.assertEquals(MessagePriority.HIGH.getImportance(), mess.getHeader("Importance", null));
Assert.assertTrue(mess.getHeader("Content-Type", null).startsWith("multipart/mixed"));
Assert.assertEquals(messageId, MailUtility.headerStripper(mess.getHeader("Message-ID", null)));
MimeMultipart mixed = (MimeMultipart) mess.getContent();
BodyPart text = mixed.getBodyPart(0);
Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
Assert.assertEquals(1, mixed.getCount());
Assert.assertTrue("Incorrect Charset: " + e.getCharset(), text.getContentType().startsWith("text/plain; charset=" + e.getCharset()));
Assert.assertEquals(textBody, MailTestUtil.getStringContent(text));
EmailMessage convertedMessage = MessageConverter.convert(mess);
Assert.assertEquals(convertedMessage.getSubject(), subject);
}
use of com.outjected.email.impl.MailMessageImpl in project simple-email by codylerum.
the class MailMessageTest method testTextMailMessageSpecialCharacters.
@Test
public void testTextMailMessageSpecialCharacters() throws MessagingException, IOException {
SessionConfig mailConfig = TestMailConfigs.standardConfig();
String subject = "Sometimes subjects have speical characters like ü - " + java.util.UUID.randomUUID().toString();
String specialTextBody = "This is a Text Body with a special character - ü";
EmailMessage e;
String messageId = "1234@seam.test.com";
Wiser wiser = new Wiser(mailConfig.getServerPort());
wiser.setHostname(mailConfig.getServerHost());
try {
wiser.start();
e = new MailMessageImpl(mailConfig).from(MailTestUtil.getAddressHeader(fromName, fromAddress)).replyTo(replyToAddress).to(MailTestUtil.getAddressHeader(toName, toAddress)).subject(subject).bodyText(specialTextBody).importance(MessagePriority.HIGH).messageId(messageId).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.decodeText(MimeUtility.unfold(mess.getHeader("Subject", null))));
MimeMultipart mixed = (MimeMultipart) mess.getContent();
BodyPart text = mixed.getBodyPart(0);
Assert.assertTrue(mixed.getContentType().startsWith("multipart/mixed"));
Assert.assertEquals(1, mixed.getCount());
Assert.assertTrue("Incorrect Charset: " + e.getCharset(), text.getContentType().startsWith("text/plain; charset=" + e.getCharset()));
Assert.assertEquals(specialTextBody, MimeUtility.decodeText(MailTestUtil.getStringContent(text)));
EmailMessage convertedMessage = MessageConverter.convert(mess);
Assert.assertEquals(convertedMessage.getSubject(), subject);
}
Aggregations