Search in sources :

Example 11 with Recipient

use of org.simplejavamail.api.email.Recipient 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 12 with Recipient

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

the class EmailPopulatingBuilderImpl1Test method testAddRecipients_Basic_Named.

@Test
public void testAddRecipients_Basic_Named() {
    builder.to("name1", "1@domain.com");
    builder.cc("name2", "2@domain.com,3@domain.com");
    builder.bcc("name3", "4@domain.com;5@domain.com");
    builder.to("name4", "6@domain.com;7@domain.com,8@domain.com");
    assertThat(builder.buildEmail().getRecipients()).containsExactlyInAnyOrder(new Recipient("name1", "1@domain.com", TO), new Recipient("name2", "2@domain.com", CC), new Recipient("name2", "3@domain.com", CC), new Recipient("name3", "4@domain.com", BCC), new Recipient("name3", "5@domain.com", BCC), new Recipient("name4", "6@domain.com", TO), new Recipient("name4", "7@domain.com", TO), new Recipient("name4", "8@domain.com", TO));
}
Also used : Recipient(org.simplejavamail.api.email.Recipient) Test(org.junit.Test)

Example 13 with Recipient

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

the class EmailPopulatingBuilderImpl1Test method testAddRecipientsVarArgs_Complex_Nameless.

@Test
public void testAddRecipientsVarArgs_Complex_Nameless() {
    builder.to("name1b <1@domain.com>");
    builder.ccMultiple("name2b <2@domain.com>", "name3b <3@domain.com>");
    assertThat(builder.getRecipients()).containsExactlyInAnyOrder(new Recipient("name1b", "1@domain.com", TO), new Recipient("name2b", "2@domain.com", CC), new Recipient("name3b", "3@domain.com", CC));
}
Also used : Recipient(org.simplejavamail.api.email.Recipient) Test(org.junit.Test)

Example 14 with Recipient

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

the class EmailPopulatingBuilderImpl1Test method testBuilderBounceToAddress.

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

Example 15 with Recipient

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

the class EmailPopulatingBuilderImpl1Test method testAddRecipients_Complex_Named.

@Test
public void testAddRecipients_Complex_Named() {
    builder.toWithDefaultName("name1", "name1b <1@domain.com>");
    builder.ccWithDefaultName("name2", "name2b <2@domain.com>,3@domain.com");
    builder.bccWithDefaultName("name3", "4@domain.com;name3b <5@domain.com>");
    builder.toWithDefaultName("name4", "name4b <6@domain.com>;name5b <7@domain.com>,name6b <8@domain.com>");
    assertThat(builder.buildEmail().getRecipients()).containsExactlyInAnyOrder(new Recipient("name1b", "1@domain.com", TO), new Recipient("name2b", "2@domain.com", CC), new Recipient("name2", "3@domain.com", CC), new Recipient("name3", "4@domain.com", BCC), new Recipient("name3b", "5@domain.com", BCC), new Recipient("name4b", "6@domain.com", TO), new Recipient("name5b", "7@domain.com", TO), new Recipient("name6b", "8@domain.com", TO));
}
Also used : Recipient(org.simplejavamail.api.email.Recipient) Test(org.junit.Test)

Aggregations

Recipient (org.simplejavamail.api.email.Recipient)56 Test (org.junit.Test)43 Email (org.simplejavamail.api.email.Email)31 File (java.io.File)10 AttachmentResource (org.simplejavamail.api.email.AttachmentResource)7 InternetAddress (jakarta.mail.internet.InternetAddress)4 NotNull (org.jetbrains.annotations.NotNull)4 EmailPopulatingBuilder (org.simplejavamail.api.email.EmailPopulatingBuilder)4 EmailConverter.mimeMessageToEmail (org.simplejavamail.converter.EmailConverter.mimeMessageToEmail)4 Address (jakarta.mail.Address)2 MimeMessage (jakarta.mail.internet.MimeMessage)2 InputStream (java.io.InputStream)2 Collection (java.util.Collection)2 Map (java.util.Map)2 HashedMap (org.apache.commons.collections4.map.HashedMap)2 Property (org.simplejavamail.config.ConfigLoader.Property)2 InternalEmailPopulatingBuilder (org.simplejavamail.email.internal.InternalEmailPopulatingBuilder)2 Test (org.testng.annotations.Test)2 EmailHelper (testutil.EmailHelper)2 MimeMessageAndEnvelope (testutil.testrules.MimeMessageAndEnvelope)2