actionmailer编码 - 在电子邮件客户端中呈现垃圾 [英] actionmailer encoding - rendering garbage in email client
问题描述
我有电子邮件的文本和HTML部分。在电子邮件包含来自数据库的值的情况下,用户报告垃圾字符。当涉及unicode字符时,这似乎是一个问题。我创建了一个简单的模板,只是回显了文本和html部分的值(<%= @body_text%>
)并用一个示例字符串测试:
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:
永久性功能ë
当我在gmail中看到此字符串时,它如下所示:
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
Content-Type: multipart/alternative; charset=UTF-8 Content-Transfer-Encoding: 7bit
,然后是文本部分:
Content-Type:text / plain; charset = UTF-8 Content-Transfer-Encoding:
base64
Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: base64
和html部分:
Content-Type:text / html; charset = UTF-8 Content-Transfer-Encoding:
quoted-printable
Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
ruby 1.9.2,rails 3.2.6
ruby 1.9.2, rails 3.2.6
推荐答案
根本原因被确定为premailer-rails3 gem == 1.2.0。迁移到actionmailer_inline_css gem已解决。
Root cause was identified as premailer-rails3 gem == 1.2.0. Migrating to actionmailer_inline_css gem resolved.
这篇关于actionmailer编码 - 在电子邮件客户端中呈现垃圾的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!