in commons-email2-jakarta/src/main/java/org/apache/commons/mail2/jakarta/Email.java [631:658]
private InternetAddress createInternetAddress(final String email, final String name, final String charsetName) throws EmailException {
try {
final InternetAddress address;
try {
address = new InternetAddress(new IDNEmailAddressConverter().toASCII(email));
} catch (final IllegalArgumentException e) {
throw new EmailException(e);
}
// check name input
if (EmailUtils.isNotEmpty(name)) {
// check charset input.
if (EmailUtils.isEmpty(charsetName)) {
address.setPersonal(name);
} else {
// canonicalize the charset name and make sure
// the current platform supports it.
final Charset set = Charset.forName(charsetName);
address.setPersonal(name, set.name());
}
}
// run sanity check on new InternetAddress object; if this fails
// it will throw AddressException.
address.validate();
return address;
} catch (final AddressException | UnsupportedEncodingException e) {
throw new EmailException(e);
}
}