# Weird Character Encoding Issue in ActionMailer

**URL:** <https://www.ruby-forum.com/t/weird-character-encoding-issue-in-actionmailer/140314>\
**Category:** Rails\
**Created:** [June 12, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/weird-character-encoding-issue-in-actionmailer/140314 "2008-06-12T21:51:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 12, 2008, 9:51pm UTC](https://www.ruby-forum.com/t/weird-character-encoding-issue-in-actionmailer/140314/1 "2008-06-12T21:51:03Z")

</div>

Hey,

I have my application setup so that e-mail templates are stored in the  
database, and each time an e-mail is sent out, a new entry is entered  
into the database with the email\_template\_id, what e-mail-specific  
variables must be included in the template (ex. a user’s first name, a  
product URL, etc.) that change with each e-mail. A process then runs  
in the background and takes these e-mails, replaces the e-mail-  
specific variables into the template, and mails it out.

When the e-mail-specific variables are put in the database, they first  
get converted into YAML, so if a user’s name was Brontë, it becomes  
Bront\xC3\xAB in the YAML format.

When the variables (such as the first name) get loaded by the process  
back into the e-mail from the database YAML, in IRB I see that the  
body text of the e-mail has the name correctly converted back to  
“Brontë”:

In IRB:

> > email\_instance.get\_body  
> > =\> "Hi Brontë (rest of email)

However, when this e-mail gets passed to ActionMailer and delivered,  
the e-mail appears as:

Hi Bront=C3=AB,

The charset attribute on the e-mails is UTF-8 (the ActionMailer  
default) which isn’t overridden when the mail is sent.

Any ideas?

---

<div class="post-metadata">

**Author:** ![john\_old](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9f8e36/32.png) [@john\_old](https://www.ruby-forum.com/u/john_old)\
**Post date:** [June 13, 2008, 7:47am UTC](https://www.ruby-forum.com/t/weird-character-encoding-issue-in-actionmailer/140314/2 "2008-06-13T07:47:34Z")

</div>

hi,

You can set the mail headers for text/html apart frmo that like wat u  
have done UTF-8 is proper…

also u can see that the table field is set to UTF format that might also  
solve th e issue

thanks

Dhaval P.  
Software Engineer

> **[RailsHouse : Ruby on Rails Development & Consulting, Waterloo, Canada](https://railshouse.com)**
>
> RailsHouse is Waterloo, Ontario based Ruby on Rails Consultancy firm which provides RoR Development, Migration, Staffing, Maintenace and Support Services

sales(AT)railshouse(DOT)com
