Rails:邮件和文本部分的UTF-8编码问题 [英] Rails: UTF-8 encoding issue with mailer and text partials
问题描述
它可以很好地与html邮件程序,因为我可以设置
< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
但是这不可能与文本邮件程序。 文本邮件程序中的问题示例(my_mailer.text.erb)
D&#233; monstration#Démonstration
我的邮件摘录:
邮件来自:< from> ,
to:< to>,
subject:< subject>
body:< body>
我还尝试添加 charset:'utf-8'
属性到邮件方法没有成功。
如何解决这个编码问题?
感谢您的帮助!
我的项目:
- Rails 5.0.1
- Ruby 2.3.3
-
- Inky-rb 宝石(邮件的基础模板渲染器)
我终于找到了我的问题。这是来自 inky-rb 宝石,它有一些问题可以理解编码。
我只是重命名我的布局(或模板),如下所示:
#app / views / layouts
default.text.inky#=> default.text.erb
I am building a Rails application and am face of a problem with my text mailer: I can’t find how to make special character (é, è, à, …) to be encoded properly.
It works great with html mailer because I can set the <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
but that’s not possible with text mailer.
Example of issue in text mailer (my_mailer.text.erb)
Démonstration # Démonstration
Extract of my mailer:
mail from: <from>,
to: <to>,
subject: <subject>,
body: <body>
I also tried to add charset: 'utf-8'
property to the mail method without success either.
How can I fix this encoding issue ?
Thanks for your help !
My project:
- Rails 5.0.1
- Ruby 2.3.3
- Inky-rb gem (Foundation template renderer for mailers)
I finally found my issue. It was coming from the inky-rb gem which has some problem to understand encoding.
I just rename my layout (or template) like this:
# app/views/layouts
default.text.inky # => default.text.erb
这篇关于Rails:邮件和文本部分的UTF-8编码问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!