473,503 Members | 3,497 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

correctly getting utf8 characters in the content of an e-mail

Hi,

The HTML of my website is produced in UTF-8.
I've got a contact form with a simple textearea.

When I send this text :
----------------
This is some text
with a second line
----------------

My PHP script sends it ($message) by e-mail :

mail('me@localhost', 'message from contact', utf8_decode($message)) ;

This is what I get in the e-mail :

This is some textwith a second line

I can't get the "\n" character.

I also tried this way :

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail('me@localhost', 'message from contact', utf8_decode(nl2br($message)),
$headers) ;

I still get the same thing :

This is some textwith a second line

How can I get the "\n" of the message correctly ?

Thank you in advance,

:: Lionel ::
Aug 9 '07 #1
2 2582
On Aug 9, 3:12 am, "lionel" <lio...@nospam.orgwrote:
Hi,

The HTML of my website is produced in UTF-8.
I've got a contact form with a simple textearea.

When I send this text :
----------------
This is some text
with a second line
----------------

My PHP script sends it ($message) by e-mail :

mail('me@localhost', 'message from contact', utf8_decode($message)) ;

This is what I get in the e-mail :

This is some textwith a second line

I can't get the "\n" character.

I also tried this way :

$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
mail('me@localhost', 'message from contact', utf8_decode(nl2br($message)),
$headers) ;

I still get the same thing :

This is some textwith a second line

How can I get the "\n" of the message correctly ?

Thank you in advance,

:: Lionel ::

If you need to handle UTF-8 I found the following library to be
helpful. As far as I can remember, this will actually translate it
into a corresponding ASCII string, so I don't think any mail servers
that also have issues with UTF-8 should have any issues either. Hope
it helps!

http://www.phpwact.org/php/i18n/utf-8
Aug 9 '07 #2
If you need to handle UTF-8 I found the following library to be
helpful. As far as I can remember, this will actually translate it
into a corresponding ASCII string, so I don't think any mail servers
that also have issues with UTF-8 should have any issues either. Hope
it helps!

http://www.phpwact.org/php/i18n/utf-8
Thanks !

I've found what the pb was : I sent the textarea content via an ajax get
query. after tracing each character and its ascii code, it appears that the
"\r\n" characters are present before the ajax get query (traced without pb
in javascript) and disappears in the php code. I used the following trick. I
replaced "\r\n" by "__r__n" in javascript and I replace "__r__n" by "\r\n"
in php. I assume it's not really a solution but I couldn't find any better
one. maybe sending in an ajax post query could solve the pb, I didn't try.

:: Lionel ::
Aug 11 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
18312
by: Spamtrap | last post by:
I only work in Perl occasionaly, and have been searching for a solution for a conversion, and everything I found seems much too complex. All I need to do is take a simple text file and copy...
1
4270
by: Paul | last post by:
Assume you have two varchar (or Text) columns named L and U which are identical except that the charset for L is latin1 and the charset for U is utf8. All the records in L and U are identical in...
7
1655
by: u260044 | last post by:
I have a problem where the French translation for "side" gets converted incorrectly into a datatable from XML. Note: The total XML is at the bottom of the message to keep from distracting from...
4
11487
by: H Lee | last post by:
Hi, I'm an XML newbie, and not sure if this is the appropriate newsgroup to post my question, so feel free to suggest other newgroups where I should post this message if this is the case. I'm...
8
20247
by: csanjith | last post by:
Hi, i have a situaion where i need to convert the characters entered in an text field to upper case using C. The configuration id utf8 environment in which user can enter any character (single ,...
18
1587
by: kenny | last post by:
I have a String outputhex which consists of unicodetext translated into hex. example: test = 7400650073007400 now i translate each two characters of the hexstring (outputhex) into byte and then...
4
2761
by: twigster | last post by:
Hi, I've a pb with utf8 encoding with safari or firefox. I retrieve the response of a XMLHttpRequest and depending if I use safari or firefox I can't manage to get characters like "éŕç" to...
2
10267
by: Jason | last post by:
Hi, I was wondering if anyone could advise me on this. Right now I am setting up a DB2 UDB V8.2.3 database with UTF8 character set, which will work with a J2EE application running on...
7
13013
by: amygdala | last post by:
Hi, I'm trying to let PHP write a 'sitemap.xml' sitemap for Google and other searchengines. It's working, except that the content in the XML file doesn't seem to be UTF8. (Which it should be,...
3
7439
by: Jake | last post by:
I am writing a script that allows people to upload a CSV file for processing and I am having trouble with accented characters. If a UTF-8 encoded file is uploaded, everything works fine. The...
0
7192
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7445
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5559
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4665
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.