Search in sources :

Example 26 with Email

use of org.simplejavamail.api.email.Email in project simple-java-mail by bbottema.

the class EmailPopulatingBuilderImpl1Test method testBuilderBCCAddresses_ComplexFormat.

@Test
public void testBuilderBCCAddresses_ComplexFormat() {
    final Email email = builder.bccWithDefaultName("1", "1b <1@candyshop.org>").bcc("5b <5@candyshop.org>").bcc("6@candyshop.org,7b <7@candyshop.org>").bcc("8b <8@candyshop.org>;9@candyshop.org").bcc("10b <10@candyshop.org>;11b <11@candyshop.org>,12@candyshop.org").buildEmail();
    assertThat(email.getRecipients()).containsExactlyInAnyOrder(createRecipient("1b", "1@candyshop.org", Message.RecipientType.BCC), createRecipient("5b", "5@candyshop.org", Message.RecipientType.BCC), createRecipient(null, "6@candyshop.org", Message.RecipientType.BCC), createRecipient("7b", "7@candyshop.org", Message.RecipientType.BCC), createRecipient("8b", "8@candyshop.org", Message.RecipientType.BCC), createRecipient(null, "9@candyshop.org", Message.RecipientType.BCC), createRecipient("10b", "10@candyshop.org", Message.RecipientType.BCC), createRecipient("11b", "11@candyshop.org", Message.RecipientType.BCC), createRecipient(null, "12@candyshop.org", Message.RecipientType.BCC));
}
Also used : Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Example 27 with Email

use of org.simplejavamail.api.email.Email in project simple-java-mail by bbottema.

the class EmailPopulatingBuilderImpl1Test method testBuilderToAddresses_ComplexFormat.

@Test
public void testBuilderToAddresses_ComplexFormat() {
    final Email email = builder.toWithDefaultName("1", "1b <1@candyshop.org>").to("5b <5@candyshop.org>").to("6@candyshop.org,7b <7@candyshop.org>").to("8b <8@candyshop.org>;9@candyshop.org").to("10b <10@candyshop.org>;11b <11@candyshop.org>,12@candyshop.org").buildEmail();
    assertThat(email.getRecipients()).containsExactlyInAnyOrder(createRecipient("1b", "1@candyshop.org", Message.RecipientType.TO), createRecipient("5b", "5@candyshop.org", Message.RecipientType.TO), createRecipient(null, "6@candyshop.org", Message.RecipientType.TO), createRecipient("7b", "7@candyshop.org", Message.RecipientType.TO), createRecipient("8b", "8@candyshop.org", Message.RecipientType.TO), createRecipient(null, "9@candyshop.org", Message.RecipientType.TO), createRecipient("10b", "10@candyshop.org", Message.RecipientType.TO), createRecipient("11b", "11@candyshop.org", Message.RecipientType.TO), createRecipient(null, "12@candyshop.org", Message.RecipientType.TO));
}
Also used : Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Example 28 with Email

use of org.simplejavamail.api.email.Email in project simple-java-mail by bbottema.

the class EmailPopulatingBuilderImpl1Test method testBuilderReturnReceiptToAddressNative.

@Test
public void testBuilderReturnReceiptToAddressNative() throws UnsupportedEncodingException {
    final Email email = builder.withReturnReceiptTo(new InternetAddress("lol.pop@somemail.com", "moo")).buildEmail();
    assertThat(email.getReturnReceiptTo().getName()).isEqualTo("moo");
    assertThat(email.getReturnReceiptTo().getAddress()).isEqualTo("lol.pop@somemail.com");
    assertThat(email.getReturnReceiptTo().getType()).isNull();
}
Also used : InternetAddress(jakarta.mail.internet.InternetAddress) Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Example 29 with Email

use of org.simplejavamail.api.email.Email in project simple-java-mail by bbottema.

the class EmailPopulatingBuilderImpl1Test method testBuilderReturnReceiptToAddressWithFixedName.

@Test
public void testBuilderReturnReceiptToAddressWithFixedName() {
    final Email email = builder.withReturnReceiptTo("lollypop", "lol.pop@somemail.com").buildEmail();
    assertThat(email.getReturnReceiptTo().getName()).isEqualTo("lollypop");
    assertThat(email.getReturnReceiptTo().getAddress()).isEqualTo("lol.pop@somemail.com");
    assertThat(email.getReturnReceiptTo().getType()).isNull();
}
Also used : Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Example 30 with Email

use of org.simplejavamail.api.email.Email in project simple-java-mail by bbottema.

the class EmailPopulatingBuilderImpl1Test method testPrependTextHTML_ToEmptyText.

@Test
public void testPrependTextHTML_ToEmptyText() {
    Email test = builder.prependTextHTML("test").buildEmail();
    EmailAssert.assertThat(test).hasHTMLText("test");
}
Also used : Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Aggregations

Email (org.simplejavamail.api.email.Email)121 Test (org.junit.Test)101 Recipient (org.simplejavamail.api.email.Recipient)31 File (java.io.File)26 EmailPopulatingBuilder (org.simplejavamail.api.email.EmailPopulatingBuilder)15 MimeMessage (jakarta.mail.internet.MimeMessage)10 EmailConverter.mimeMessageToEmail (org.simplejavamail.converter.EmailConverter.mimeMessageToEmail)10 InternalEmailPopulatingBuilder (org.simplejavamail.email.internal.InternalEmailPopulatingBuilder)7 URL (java.net.URL)6 AttachmentResource (org.simplejavamail.api.email.AttachmentResource)6 ByteArrayDataSource (jakarta.mail.util.ByteArrayDataSource)5 InternetAddress (jakarta.mail.internet.InternetAddress)4 Date (java.util.Date)4 SpEmail (org.apache.streampipes.model.mail.SpEmail)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3 GregorianCalendar (java.util.GregorianCalendar)3 HashedMap (org.apache.commons.collections4.map.HashedMap)3 NotNull (org.jetbrains.annotations.NotNull)3 MimeMessageAndEnvelope (testutil.testrules.MimeMessageAndEnvelope)3 IOException (java.io.IOException)2