Reputation: 601
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!
Upvotes: 6
Views: 3119
Reputation: 256
Even i was facing the similar issue, we need to ensure we are setting encoding as base64 to resolve the issue.
class YourMailerClass < ActionMailer::Base
default from: '[email protected]'
default bcc: '[email protected]'
def send_mail
email = "[email protected]"
mail(
subject: "subject goes here",
to: email,
content_type: 'text/xml',
encoding: "base64" // ensure encoding is passed as "base64"
)
end
end
Upvotes: 0
Reputation: 1
I solved my problem by adding default 'Content-Transfer-Encoding' => '7bit'
to my ActionMailer
.
Have a look at the API docs.
Upvotes: 0
Reputation: 601
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.
Upvotes: 2