Search in sources :

Example 96 with Email

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

the class EmailPopulatingBuilderImpl1Test method testBuilderCCAddresses_ComplexFormat.

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

Example 97 with Email

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

the class EmailPopulatingBuilderImpl1Test method testAppendText_ToEmptyText.

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

Example 98 with Email

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

the class EmailPopulatingBuilderImpl1Test method testSignWithSmime_WithConfigObject.

@Test
public void testSignWithSmime_WithConfigObject() {
    builder.signWithSmime(loadPkcs12KeyStore());
    final Email email = builder.buildEmail();
    assertThat(email.getPkcs12ConfigForSmimeSigning()).isNotNull();
    assertThat(email.getPkcs12ConfigForSmimeSigning().getPkcs12StoreData()).isNotNull();
    assertThat(email.getPkcs12ConfigForSmimeSigning().getStorePassword()).isEqualTo("letmein".toCharArray());
    assertThat(email.getPkcs12ConfigForSmimeSigning().getKeyAlias()).isEqualTo("smime_test_user_alias");
    assertThat(email.getPkcs12ConfigForSmimeSigning().getKeyPassword()).isEqualTo("letmein".toCharArray());
}
Also used : Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Example 99 with Email

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

the class EmailPopulatingBuilderImpl1Test method testBuilderNotificationFlags_DefaultToReplyTo.

@Test
public void testBuilderNotificationFlags_DefaultToReplyTo() {
    final Email email = builder.withReplyTo("replyTo", "1@candyshop.org").from("from", "2@candyshop.org").withDispositionNotificationTo().withReturnReceiptTo().buildEmail();
    assertThat(email.isUseDispositionNotificationTo()).isTrue();
    assertThat(email.isUseReturnReceiptTo()).isTrue();
    assertThat(email.getDispositionNotificationTo()).isEqualTo(new Recipient("replyTo", "1@candyshop.org", null));
    assertThat(email.getReturnReceiptTo()).isEqualTo(new Recipient("replyTo", "1@candyshop.org", null));
}
Also used : Email(org.simplejavamail.api.email.Email) Recipient(org.simplejavamail.api.email.Recipient) Test(org.junit.Test)

Example 100 with Email

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

the class EmailPopulatingBuilderImpl1Test method testBuilderReturnReceiptToAddressWithFixedNameOverridingTheOneFromAddress.

@Test
public void testBuilderReturnReceiptToAddressWithFixedNameOverridingTheOneFromAddress() throws UnsupportedEncodingException {
    final Email email = builder.withReturnReceiptTo("lollypop", new InternetAddress("lol.pop@somemail.com", "moo")).buildEmail();
    assertThat(email.getReturnReceiptTo().getName()).isEqualTo("lollypop");
    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)

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