Search in sources :

Example 21 with Email

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

the class EmailPopulatingBuilderImpl1Test method testEmbeddingImagesWithDynamicDataSourceResolution_relativeFilePathWithBasedir.

@Test
public void testEmbeddingImagesWithDynamicDataSourceResolution_relativeFilePathWithBasedir() throws IOException {
    final Email email = builder.withEmbeddedImageAutoResolutionForFiles(true).withEmbeddedImageAutoResolutionForClassPathResources(true).withEmbeddedImageAutoResolutionForURLs(true).withEmbeddedImageBaseDir(RESOURCES_PATH).withHTMLText("<img src=\"cid:cid_name\"/>").appendTextHTML("<img src=\"pkcs12/about all this.txt\"/>").buildEmail();
    verifyEmbeddedImage(email, "to generate CA cert, private key and and S/MIME format");
}
Also used : Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Example 22 with Email

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

the class EmailPopulatingBuilderImpl1Test method testBuilderFromAddressOverwriteWithAlternativeBuilderMethod.

@Test
public void testBuilderFromAddressOverwriteWithAlternativeBuilderMethod() {
    final Email email = builder.from("lollypop", // should be overwritted
    "lol.pop@somemail.com").from(new Recipient("lollypop2", "lol.pop2@somemail.com", null)).buildEmail();
    assertThat(email.getFromRecipient().getName()).isEqualTo("lollypop2");
    assertThat(email.getFromRecipient().getAddress()).isEqualTo("lol.pop2@somemail.com");
    assertThat(email.getFromRecipient().getType()).isNull();
}
Also used : Email(org.simplejavamail.api.email.Email) Recipient(org.simplejavamail.api.email.Recipient) Test(org.junit.Test)

Example 23 with Email

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

the class EmailPopulatingBuilderImpl1Test method testEmbeddingImagesWithDynamicDataSourceResolution_absoluteFilePathOutsideBasedir_AllowedTrue.

@Test
public void testEmbeddingImagesWithDynamicDataSourceResolution_absoluteFilePathOutsideBasedir_AllowedTrue() throws IOException {
    final Email email = builder.withEmbeddedImageAutoResolutionForFiles(true).withEmbeddedImageAutoResolutionForClassPathResources(true).withEmbeddedImageAutoResolutionForURLs(true).withEmbeddedImageBaseDir(RESOURCES_PATH + "/pkcs12").allowingEmbeddedImageOutsideBaseDir(true).withHTMLText("<img src=\"cid:cid_name\"/>").appendTextHTML("<img src=\"" + RESOURCES_PATH + "/log4j2.xml\"/>").buildEmail();
    verifyEmbeddedImage(email, "<Console name=\"console\" target=\"SYSTEM_OUT\">");
}
Also used : Email(org.simplejavamail.api.email.Email) Test(org.junit.Test)

Example 24 with Email

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

the class EmailPopulatingBuilderImpl1Test method testBuilderFromAddress.

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

Example 25 with Email

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

the class EmailPopulatingBuilderImpl1Test method testPrependText_ToEmptyText.

@Test
public void testPrependText_ToEmptyText() {
    Email test = builder.prependText("test").buildEmail();
    EmailAssert.assertThat(test).hasPlainText("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