问题
I have both text and html parts for my emails. Users are reporting 'garbage characters' in some cases where the email is include values from the db. It seems to be an issue when unicode characters are involved. I created trivial template that just echos back the value for both the text and html parts (<%= @body_text %>
) and tested it out with a sample string:
a permanent feature ë
When I see this string in gmail it looks like:
a permanent feature ������
Inspecting the header I see this on the mail:
Content-Type: multipart/alternative; charset=UTF-8 Content-Transfer-Encoding: 7bit
and then the text part:
Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64
and the html part:
Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
ruby 1.9.2, rails 3.2.6
回答1:
Root cause was identified as premailer-rails3 gem == 1.2.0. Migrating to actionmailer_inline_css gem resolved.
来源:https://stackoverflow.com/questions/11477739/actionmailer-encoding-rendering-garbage-in-email-client