title: How to send UTF-8 encoded email body with JavaMailSenderImpl?
body: <p>I am sending an email this way:</p>
  
  <pre><code>@Test
  public void testEmailCharacterSet() throws MessagingException, UnsupportedEncodingException {
      JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
      mailSender.setDefaultEncoding("utf-8");
      mailSender.setHost("*****");
      mailSender.setUsername("*****");
      mailSender.setPassword("*****");
  
      Properties properties = new Properties();
      properties.setProperty("mail.mime.charset", "utf-8");
  
      mailSender.setJavaMailProperties(properties);
  
      MimeMessage mimeMessage = mailSender.createMimeMessage();
      MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false, "utf-8");
      mimeMessage.setContent("Árvíztűrő tükörfúrógép 3", "text/html"); 
      helper.setFrom("noreply@foobar.com");
      helper.setTo("foobar@gmail.com");
  
      mailSender.send(mimeMessage);
  }
  </code></pre>
  
  <p>As you can see I am setting utf-8 everywhere when I can. My problem is that the outgoing raw bytes are still in Latin1, at least this is what I see in Wireshark:</p>
  
  <pre><code>Date: Sun, 17 May 2015 18:16:21 +0200 (CEST)
  From: noreply@foobar.com
  To: foobar@gmail.com
  Message-ID: &lt;13648335.0.1431879381653.JavaMail.foo@foo-dell&gt;
  MIME-Version: 1.0
  Content-Type: text/html; charset=UTF-8
  Content-Transfer-Encoding: quoted-printable
  
  =C1rv=EDzt?r? t=FCk=F6rf=FAr=F3g=E9p 3
  .
  </code></pre>
  
  <p>So basically the headers are saying UTF-8, but the outgoing bytes already contain question mark where ő and ű should appear, which are two characters that are missing from Latin1. The JVM's <code>file.encoding</code> is not UTF-8, but I am looking for a way to keep that as it is and solve this problem only in the emailing side.</p>
  
  <p>Thanks!</p>
  
  <p><strong>Update</strong></p>
  
  <p>I have previously successfully used the plain old method to send email, and it's interesting that that still works:</p>
  
  <pre><code>Message mimeMessage = new MimeMessage(session);
  mimeMessage.setContent("Árvíztűrő tükörfúrógép 7 oldschool", "text/html; charset=utf-8"); 
  </code></pre>
  
  <p>So it's clearly something specific to the <code>JavaMailSenderImpl</code> only.</p>