1

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?

Eric J.
  • 147,927
  • 63
  • 340
  • 553

1 Answers1

2

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.

Eric J.
  • 147,927
  • 63
  • 340
  • 553
Robert Bratton
  • 435
  • 1
  • 5
  • 12
  • Answers that only link to an external source are not considered good answers in Stack Overflow. Answers should be self-contained, but certainly may reference external sources to provide background or additional information. Typically, link-only answers will be deleted by the community. Since you are a new user, I have edited your answer. I'm validating whether it solves the problem (I do not use non-ASCII characters as was the case in the link, but the UTF-8 encoding may solve the problem anyhow) – Eric J. Apr 18 '13 at 17:37