Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

actionmailer encoding - rendering garbage in email client

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

like image 519
Mark Nadig Avatar asked Nov 14 '22 02:11

Mark Nadig


1 Answers

Root cause was identified as premailer-rails3 gem == 1.2.0. Migrating to actionmailer_inline_css gem resolved.

like image 107
Mark Nadig Avatar answered Dec 26 '22 00:12

Mark Nadig