I've an issue on the from name when I send mail with the Mailer by Ruby On Rails (Rails 4.1.4).
The from name is not encoded with utf-8 when I put hook inside the mail.
Kévin GUIOT work and return the correct name encoded. Kévin GUIOT [MyCompagny] does't work and return =?UTF-8?Q?K=C3=A9vin_GUIOT_[MyCompagny]_ .
Can u help me please ?
Thanks.
Here is my code:
class TemplateMailer < ActionMailer::Base
def send_mail(email, subject, content, template_mail)
from = "Kévin GUIOT [MyCompagny] <kevin.guiot@mycompagny.com>"
mail(to: email, subject: subject, from: from) do |format|
format.html { render html: content.html_safe }
end
end
end
Valid from with correct encoding:
from = "Kévin GUIOT <kevin.guiot@mycompagny.com>"
Invalid from with incorrect encoding (with hook):
from = "Kévin GUIOT [MyCompagny] <kevin.guiot@mycompagny.com>"
I look my emails with Outlook and the email is sended with a windows machine.
答案 0 :(得分:1)
答案 1 :(得分:0)
尝试将此行添加到文件顶部
# -*- coding: utf-8 -*-