-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #340 from eikek/encode-address
Add a fallback and logging when converting addresses to javamail
- Loading branch information
Showing
2 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,9 @@ import cats.effect._ | |
import cats.effect.unsafe.implicits.global | ||
import emil._ | ||
import emil.builder._ | ||
import emil.javamail.conv._ | ||
import emil.javamail.syntax._ | ||
import jakarta.mail.internet.InternetAddress | ||
import munit._ | ||
|
||
class MailConvTest extends FunSuite { | ||
|
@@ -23,6 +25,21 @@ class MailConvTest extends FunSuite { | |
) | ||
} | ||
|
||
test("write mail address") { | ||
val ma1 = MailAddress.unsafe(Some("a;b;c"), "me@localhost") | ||
val ma2 = MailAddress.unsafe(Some("a;b;c"), "me<@localhost") | ||
val ma3 = MailAddress.unsafe(Some("Company name"), "[email protected]") | ||
val addrConv = encode.mailAddressEncode | ||
|
||
assertEquals(addrConv.convert(ma1), new InternetAddress("me@localhost")) | ||
intercept[Exception](addrConv.convert(ma2)) | ||
assertEquals( | ||
addrConv.convert(ma3), | ||
new InternetAddress("\"Company name\" <[email protected]>") | ||
) | ||
assertEquals(addrConv.convert(ma3), new InternetAddress(ma3.displayString)) | ||
} | ||
|
||
test("write text mail") { | ||
val mail = MailBuilder.build[IO]( | ||
From("[email protected]"), | ||
|