title: Cannot use Sendgrid Java API to send UTF-8 encoded emails
body: <p>I've just switched from Mandrill to Sendgrid. When using the standard Sendgrid JAVA API to send emails the email header content-type is listed as:</p>
  <pre><code>Content-Type: text/html; charset=iso-8859-1
  </code></pre>
  <p>I have not been able to find a way to change this to UTF-8 which is my requirement for sending properly encoded emails. This worked just fine when using Mandrill. Sending via Mandrill kept the original source encoding intact in the content-type header. My current code is basically using this Sendgrid sample code:
  <a href="https://sendgrid.com/docs/for-developers/sending-email/v3-java-code-example/" rel="noreferrer">https://sendgrid.com/docs/for-developers/sending-email/v3-java-code-example/</a></p>
  <p><strong>Environment:</strong></p>
  <ul>
  <li>JDK 1.8</li>
  <li>sendgrid-java 4.48</li>
  </ul>
  <p>My source files are all encoded with UTF-8 and my project is built via Maven with maven-compiler-plugin set to</p>
  <pre><code>&lt;encoding&gt;UTF-8&lt;/encoding&gt;
  </code></pre>
  <p>The messsage body that I am posting to Sendgrid is HTML and has the following content-type set in the head element:</p>
  <pre><code>&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=utf-8&quot; /&gt;
  </code></pre>
  <p>The results of using Sendgrid is that the message gets clipped in Gmail. This seems to be due to the conflicting encoding types. Ie the &quot;mail&quot; header says iso-8859-1 even though the actual content is UTF-8. If I understand this correctly the result is that characters are encoded incorretly.</p>
  <p>Note: I'm sending Norwegian characters ÆØÅ.</p>
  <p>I've tried to convert the message body to ASCII and iso-8859-1. The results of this is that the email is no longer clipped in Gmail, but the ÆØÅ characters are replaced with questionmarks (I know that US_ASCII does not support the ÆØÅ characters). I've also tried to override the Sendgrid header with this code:</p>
  <pre><code>mail.addHeader(&quot;Content-Type&quot;, &quot;text/html; charset=UTF-8&quot;);
  </code></pre>
  <p>But that key is reserved and cannot be overriden..</p>
  <p>I've also contacted Sendgrid support. They replied with the following:</p>
  <blockquote>
  <p>Unfortunately, our system will automatically encode the body with
  whatever encoding is being passed to us. This means, that if there are
  characters in that email that are ISO-8859 characters. Then the body
  is going to be using that encoding. We do not currently have an option
  to force UTF-8 encode the body of emails that are being passed through
  us.</p>
  <p>Going forward, you would need to convert these emails previous to
  sending them to our servers. Or put a procedure in place to decode
  them into UTF-8 when they are received. For more in depth help with
  code, I would suggest reaching out of the GitHub issue board of the
  language you're using is a great way to gain insight:
  <a href="https://github.com/sendgrid/sendgrid-java" rel="noreferrer">https://github.com/sendgrid/sendgrid-java</a>.</p>
  </blockquote>