Send e-mail with charset iso-8859-1

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

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

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)

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.