Skip to content

Improve support for Email Address Internationalization (EAI) #589

Description

@j-bernard

EAI is defined in RFC6531 and is supported by Jakarta Mail with the SMTPUTF8 extension but some email addresses domains are considered invalid while they shouldn't when creating InternetAddress.
To fully support EAI, InternetAddress.checkAddress should be fixed.

We made some tests with various valid email addresses and noticed the following elements:

  • if the domain part is not in normalization form NFC it is rejected
  • some valid Unicode domains are not accepted

The local part is correctly handled in our test cases.

In order to fix the domain part handling, InternetAddress.checkAddress should implement IDNA 2008 support as defined in RFC5891, an easy fix is to check the conversion of the domain to A-label with ICU4j that offers a good compliance with IDNA 2008.

Our test were done on Android and written in Kotlin with Jakarta version 2.0.1 but platform and language should not change anything here.

Here is a Kotlin snippet to check IDN conversion to A-label:

boolean isDomainValid(String domain) {
    int flags = IDNA.CHECK_BIDI | IDNA.CHECK_CONTEXTJ | IDNA.CHECK_CONTEXTO | IDNA.NONTRANSITIONAL_TO_ASCII | IDNA.USE_STD3_RULES;
    IDNA idna = IDNA.getUTS46Instance(flags);
    IDNA.Info info = new IDNA.Info();
    idna.nameToASCII(domain, new StringBuilder(), info);
    return !info.hasErrors();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions