Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails ActionMailer encoding

Setup:

Ruby 1.9.2
Rails 3.2.2

I'm having some trouble with the encoding of my emails.

Note: I'm not that familiar with encoding and stuff like that.

When sending an email with ActionMailer, something weird is going on with the html in the email.

All equal(=) signs are getting changed to =3D. Example:

<table border=3D"0" cellpadding=3D"0" cellspacing=3D"0" width=3D"=440">
  <tbody>
    <tr>
      <td height=3D"10">   </td>
    </tr>
  </tbody>
</table>

Special characters looks like this: ä -> ä.

It looks great in local development, but when using SendGrid on production server, special characters don't work.

I'm sure this is because my lack of understanding.

Here's the mail Header:

Mime-Version: 1.0
Content-Type: text/html;
 charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-SMTPAPI: {"filters": {}}

Does it have anything to do with Content-Transfer-Encoding? Or should it be like that?

Maybe it's a problem with SendGrid and not my setup?

An employee at SendGrid told me this: you need to make sure your equals signs are URI-encoded, what does that mean? Thanks in advance!

like image 303
Tim Brunsmo Avatar asked Nov 13 '22 05:11

Tim Brunsmo


1 Answers

It was not a problem on my side, it was SendGrid. Mails sent through SendGrid with characters like "åäö" does not work in mail clients like yahoo/outlook/MacMail.

After a few hours of support with an employee at SendGrid the problem still persists. They say that the problem is in my setup. I've now switched to mailgun with exactly the same setup and it works great.

like image 56
Tim Brunsmo Avatar answered Dec 02 '22 13:12

Tim Brunsmo