I'm using AWS SES to send emails from a Java application using AWS SDK v2.
ASCII email addresses work fine ([email protected]
), but when I try to send email to address with non-ascii characters (myemail+早上@gmail
or myemail+й@gmail
), I don't receive anything.
Here is my code:
import jakarta.mail.internet.InternetAddress
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.ses.SesClient
import software.amazon.awssdk.services.ses.model.SendEmailRequest
import java.IDN
import java.nio.charset.StandardCharsets.UTF_8
val ses = SesClient.builder()
.region(Region.US_EAST_1)
.build()
val email1 = IDN.toASCII("[email protected]", IDN.ALLOW_UNASSIGNED) // works fine
val email2 = IDN.toASCII("myemail+早上@gmail", IDN.ALLOW_UNASSIGNED) // no exception but email is not received
val email3 = IDN.toASCII("myemail+й@gmail", IDN.ALLOW_UNASSIGNED) // no exception but email is not received
ses.sendEmail(
SendEmailRequest.builder()
.destination { it.toAddresses(email1, email2, email3) }
.message { messageBuilder ->
messageBuilder
.subject { it.data("Test").charset(UTF_8.toString()) }
.body { bodyBuilder ->
bodyBuilder
.html { it.data("<h1>Hello</h1>").charset(UTF_8.toString()) }
.text { it.data("Hello").charset(UTF_8.toString()) }
}
}
.source(InternetAddress("[email protected]", "My Email", UTF_8.toString()).toString())
.build()
)
Any idea?
I'm using AWS SES to send emails from a Java application using AWS SDK v2.
ASCII email addresses work fine ([email protected]
), but when I try to send email to address with non-ascii characters (myemail+早上@gmail
or myemail+й@gmail
), I don't receive anything.
Here is my code:
import jakarta.mail.internet.InternetAddress
import software.amazon.awssdk.regions.Region
import software.amazon.awssdk.services.ses.SesClient
import software.amazon.awssdk.services.ses.model.SendEmailRequest
import java.IDN
import java.nio.charset.StandardCharsets.UTF_8
val ses = SesClient.builder()
.region(Region.US_EAST_1)
.build()
val email1 = IDN.toASCII("[email protected]", IDN.ALLOW_UNASSIGNED) // works fine
val email2 = IDN.toASCII("myemail+早上@gmail", IDN.ALLOW_UNASSIGNED) // no exception but email is not received
val email3 = IDN.toASCII("myemail+й@gmail", IDN.ALLOW_UNASSIGNED) // no exception but email is not received
ses.sendEmail(
SendEmailRequest.builder()
.destination { it.toAddresses(email1, email2, email3) }
.message { messageBuilder ->
messageBuilder
.subject { it.data("Test").charset(UTF_8.toString()) }
.body { bodyBuilder ->
bodyBuilder
.html { it.data("<h1>Hello</h1>").charset(UTF_8.toString()) }
.text { it.data("Hello").charset(UTF_8.toString()) }
}
}
.source(InternetAddress("[email protected]", "My Email", UTF_8.toString()).toString())
.build()
)
Any idea?
Share Improve this question asked Mar 24 at 13:51 Cedric ThiebaultCedric Thiebault 1,0271 gold badge16 silver badges28 bronze badges 3 |1 Answer
Reset to default 1AWS SES only supports 7-bit ASCII in the local part of the email address (i.e. before the @
), according to their docs.
IDB.toUnicode
would be the alternative. Try"myemail+\[email protected]"
to check source code encoding. Maybe all after+
is ignored but still fails if not ASCII.. Seems a bug w.r.t. IDN_ALLOW_UNASSIGNED. – Joop Eggen Commented Mar 24 at 14:12+
). I'd suggest checking the resulting conversions. Also note that the SES documentation states no Unicode support and no Punycode in the local part of the address. – Hasturkun Commented Mar 24 at 15:13