title: Send javax.mail.internet.MimeMessage to a recipient with non-ASCII name?
body: <p>I am writing a piece of Java code that needs to send mail to users with non-ASCII names. I have figured out how to use UTF-8 for the body, subject line, and generic headers, but I am still stuck on the <strong>recipients</strong>.</p>
  
  <p>Here's what I'd like in the "To:" field: <code>"ウィキペディアにようこそ" &lt;foo@example.com&gt;</code>. This lives (for our purposes today) in a String called <code>recip</code>.</p>
  
  <ul>
  <li><code>msg.addRecipients(MimeMessage.RecipientType.TO, recip)</code> gives <code>"忙俾ェ▎S]" &lt;foo@example.com&gt;</code></li>
  <li><code>msg.addHeader("To", MimeUtility.encodeText(recip, "utf-8", "B"))</code> throws <code>AddressException: Local address contains control or whitespace in string ``=?utf-8?B?IuOCpuOCo+OCreODmuODh+OCo+OCouOBq+OCiOOBhuOBk+OBnSIgPA==?= =?utf-8?B?Zm9vQGV4YW1wbGUuY29tPg==?=''</code></li>
  </ul>
  
  <p>How the heck am I supposed to send this message?</p>
  
  <hr>
  
  <p>Here's how I handled the other components:</p>
  
  <ul>
  <li>Body HTML: <code>msg.setText(body, "UTF-8", "html");</code></li>
  <li>Headers: <code>msg.addHeader(name, MimeUtility.encodeText(value, "utf-8", "B"));</code></li>
  <li>Subject: <code>msg.setSubject(subject, "utf-8");</code></li>
  </ul>