Search code examples
asp.net-mvccharacter-encodingpostal

English Email Displays Chinese-like Characters


I'm using Postal to send emails with an HTML and Text portion.

When the email is sent to Gmail, it is displayed correctly. However, when it is displayed in at least two other email systems (Mail Enable's webmail interface, and an unknown system at a client), the text is rendered as something similar to Chinese. When the client forwards the email back to a Gmail account, the "Chinese" rendering is also visible.

Example email generated:

X-Sender: no-reply@thecompany.com
X-Receiver: therecipient@thecompany.com
MIME-Version: 1.0
From: no-reply@thecompany.com
To: therecipient@thecompany.com
Date: 17 Apr 2013 22:11:25 -0700
Subject: Some Subject
Content-Type: multipart/alternative;
 boundary=--boundary_0_83808b99-ef32-4f47-8835-ba4a435a2141


----boundary_0_83808b99-ef32-4f47-8835-ba4a435a2141
Content-Type: text/plain; charset=utf-16
Content-Transfer-Encoding: base64

MIME ENCODED CONTENTS HERE==
----boundary_0_83808b99-ef32-4f47-8835-ba4a435a2141
Content-Type: text/html; charset=utf-16
Content-Transfer-Encoding: base64

MIME ENCODED CONTENTS HERE=
----boundary_0_83808b99-ef32-4f47-8835-ba4a435a2141--

Clearly there is an encoding issue that Gmail somehow sorts out but other email servers do not, but what exactly is the issue?

The charset is specified as utf-16. Is does Postal (or the MVC engine) in fact generate utf-8 output? How can I control the encoding of the output and/or the charset specified in the email header?


Solution

  • The character encoding can be explicitly set to utf-8 by adding the headers

    Content-Type: text/plain; charset=utf-8
    and
    Content-Type: text/html; charset=utf-8
    

    See this article for more information.

    NOTE: There is a typo in the article. The text/plain line is missing a semicolon. That is corrected in the example above.