Skip to main content
Known Participant
May 7, 2006
Question

CFMAIL character set not working

  • May 7, 2006
  • 2 replies
  • 1327 views
Hi everyone,

Recently we moved our websites to CF7 and we got a lot of problems with the character sets. We support multiple languages and we started to get a lot of issues related to the german, french or any other "special" characters like ä, ü, ß or any other.
Browsing the internet I learned how to fix most of them, including "<cfprocessingdirective pageencoding="ISO-8859-1">" into all our pages but we still have one problem that I cannot fix.

Our database backend it's a mySQL 4.1.12 with "UTF-8 unicode" default character set for all the tables.

If I do a query, for instance:

<cfquery name="get" datasource="dns">
SELECT *
FROM cart
WHERE customer = 12870
</cfquery>

And then I have the following code:

<cfoutput query="get">
#deliverystreet#
</cfoutput>

<cfmail to="xxx@xxx.com" from="xxx@xxx.comm" subject="test character set" server="localhost" type="HTML" charset="ISO-8859-1">
#get.deliverystreet#
Pietiläntie 30
</cfmail>

This is what I get on the screen:

Pietiläntie 30
Pietiläntie 30

But this is what I get into the email message:

Pietil?ntie 30
Pietiläntie 30

So, in other words, works fine on the screen, but it doesn't work with CFMAIL or CFFILE no matter what CHARSET I specify for these tags. But as you can see, if I just type in the text "Pietiläntie 30" between the mail tags, the text goes fine. But If it is a variable output #var# it doesn't. I have into Application.cfm also the following code:

<cfcontent type="text/html; charset=ISO-8859-1">
<cfset setEncoding("url", "ISO-8859-1")>
<cfset setEncoding("form", "ISO-8859-1")>

I think I already tried everything with no luck to make this work! I really need help, it's been a while since I am trying to fix this and it is very very important for me. Thank you!
This topic has been closed for replies.

2 replies

Known Participant
May 7, 2006
Hallelujah!!!

I think there are 4 or 5 month since I am facing this issue and only today I found the complete solution! In order to make CFMAIL and CFFILE tags to work fine with database results. In order to make it work, all you have to do is to open the DSN connection in the Cold Fusion Administrator, click on Advanced Settings and enter the following text to the CONNECTION STRING:

useUnicode=true&characterEncoding=iso-8859-1

A complete set of instructions to fix character sets issues here: http://www.xtreme-host.com/faq/index.php?qid=81&catid=9
BKBK
Community Expert
Community Expert
May 7, 2006
I think you will avoid the problem in the first place if you leave the encoding at Coldfusion's default, UTF-8.

Known Participant
May 8, 2006
Are you talking about not using processing directive?
If so, it wouldn't work. If you don't use it, you don't have the good charset on the screen... if you use it, you don't have database results sent by email or saved to file...
Inspiring
May 7, 2006
MacLaeod wrote:
> Our database backend it's a mySQL 4.1.12 with "UTF-8 unicode" default
> character set for all the tables.

you seem to be mixing encodings. try utf-8 instead of iso-8859-1. also
what db driver are you using?