# Send e-mail with charset iso-8859-1

**URL:** <https://www.ruby-forum.com/t/send-e-mail-with-charset-iso-8859-1/128408>\
**Category:** Rails\
**Created:** [February 7, 2008, 1:54pm UTC](https://www.ruby-forum.com/t/send-e-mail-with-charset-iso-8859-1/128408 "2008-02-07T13:54:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Umulium](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/58f4c7/32.png) [@Umulium](https://www.ruby-forum.com/u/Umulium)\
**Post date:** [February 7, 2008, 1:54pm UTC](https://www.ruby-forum.com/t/send-e-mail-with-charset-iso-8859-1/128408/1 "2008-02-07T13:54:38Z")

</div>

I have a rails application that sends e-mails. The e-mails currently  
use the utf-8 charset, but I have to change this to iso-8859-1 since  
it doesn’t play well with Outlook. (Norwegian characters such as ÆØÅ  
are not displayed correctly, because Outlook doesn’t recognize the  
utf-8 charset)

1. I’ve set the default charset i the environment, but this does not  
work. (ActionMailer::Base.default\_charset = “iso-8859-1”)
2. I’ve tried to set the @charset variable, but this does not work  
either.  
@subject = ‘…’  
@recipients = ‘…’  
…  
@charset = ‘iso-8859-1’

It’s seem that rails simply ignores every attempt to change the  
charset.  
What to do??

Kind regards,  
Eivind Løland-Andersen

---

<div class="post-metadata">

**Author:** ![Umulium](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/58f4c7/32.png) [@Umulium](https://www.ruby-forum.com/u/Umulium)\
**Post date:** [April 2, 2008, 7:59pm UTC](https://www.ruby-forum.com/t/send-e-mail-with-charset-iso-8859-1/128408/2 "2008-04-02T19:59:14Z")

</div>

Umulium wrote:

> I have a rails application that sends e-mails. The e-mails currently  
> use the utf-8 charset, but I have to change this to iso-8859-1 since  
> it doesn’t play well with Outlook. (Norwegian characters such as ï¿½ï¿½ï¿½  
> are not displayed correctly, because Outlook doesn’t recognize the  
> utf-8 charset)  
> …  
> It’s seem that rails simply ignores every attempt to change the  
> charset.

we spent hours over here and were trying to get around this issue as  
well.  
while reading the actionmailer code we learned that indeed there is no  
conversion as one would like it to be when changing the charsets.

in fact the documentation is a little bit misleading.

actionmailer does no charset conversion by itself. changing the default  
charset does only change the declaration of the content but not the  
content itself.  
so the solution is - you have to do conversions by hand.

something like  
def contact\_message(message)  
from message[:email].to\_iso  
subject message[:subject].to\_iso  
body message[:body].to\_iso  
end  
might work, if your output should be some kind of iso.

cheers,  
mrIllo

---

<div class="post-metadata">

**Author:** ![Umulium](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/58f4c7/32.png) [@Umulium](https://www.ruby-forum.com/u/Umulium)\
**Post date:** [April 2, 2008, 8:16pm UTC](https://www.ruby-forum.com/t/send-e-mail-with-charset-iso-8859-1/128408/3 "2008-04-02T20:16:19Z")

</div>

and first for this above to work you have to have an initializer:

class String  
def to\_iso  
Iconv.conv(‘ISO-8859-1’, ‘utf-8’, self)  
end  
end

class NilClass  
def to\_iso  
Iconv.conv(‘ISO-8859-1’, ‘utf-8’, ‘’)  
end  
end

(code provided by railway team)

---

<div class="post-metadata">

**Author:** ![Umulium](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/58f4c7/32.png) [@Umulium](https://www.ruby-forum.com/u/Umulium)\
**Post date:** [June 2, 2009, 10:37pm UTC](https://www.ruby-forum.com/t/send-e-mail-with-charset-iso-8859-1/128408/4 "2009-06-02T22:37:26Z")

</div>

Anton HosentrÃ¤ger wrote:

> and first for this above to work you have to have an initializer:
> 
> class String  
> def to\_iso  
> Iconv.conv(‘ISO-8859-1’, ‘utf-8’, self)  
> end  
> end
> 
> class NilClass  
> def to\_iso  
> Iconv.conv(‘ISO-8859-1’, ‘utf-8’, ‘’)  
> end  
> end
> 
> (code provided by railway team)

Hi, I have the same problem with an application. I’m new in this so I  
need to know where to add theses lines you say.  
Thank you.
