actionmailer encoding - rendering garbage in email client

走远了吗. 提交于 2019-12-12 09:39:00

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!