in src/main/java/org/apache/commons/mail/Email.java [1945:1980]
private InternetAddress createInternetAddress(final String email, final String name, final String charsetName)
throws EmailException
{
InternetAddress address;
try
{
address = new InternetAddress(new IDNEmailAddressConverter().toASCII(email));
// 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();
}
catch (final AddressException | UnsupportedEncodingException e)
{
throw new EmailException(e);
}
return address;
}