Page 1 of 1

mail send with different charset

Posted: Mon Sep 15, 2003 7:15 am
by zemanel752
Hi!

I'm using mail() to send variables picked up in a flash movie to an e-mail account. The problem is that in my language (portuguese) we use accentuation in characters and the "special" chars appear like rubbish in the e-mail sent. Could you help me to work out this one?

Code: Select all

<?php 

$datestamp =(date ("dS F Y ( h:i:s A )",time())); 
$TextVariable = '&results='; 
$response = 'Message Sent'; 

$charset = "utf-8"; 

$comments = "<meta http-equiv="Content-Type" content="text/html; charset=$charset" />\n " . $comments; 

echo $TextVariable; 
echo $response; 

mail ("$mailDestination", "E-mail sent by: $name", " 

Name: $name 
E-mail:   $email 

Message
$comments 

Sent by: $REMOTE_ADDR 
Sent: $datestamp 
"); 
?>

Posted: Mon Sep 15, 2003 2:40 pm
by m3rajk
do you know the html values?

Code: Select all

&aacute;
or

Code: Select all

&#225;
umm let's see if it'll display right here when i try to show what character i used: á

if you know those, you can make a preg function to conver tot eh equivalents and send either html (&aacute;) or possibly plaintext if you use the ascii (á)

Posted: Mon Sep 15, 2003 2:42 pm
by SantaGhost
you might wanna take a look at the charset (dont know if portuguese is different)

Posted: Tue Sep 16, 2003 8:31 am
by zemanel752
the charset could be either utf-8 or windows-1252 (I think).

I believe that the function m3rajk wrote about is what I'm looking for. I really dunno how to implement it in my code, but I'll see what I find about that. oh, and the codes used are like these:

Code: Select all

&aacute;
and it apears like it should in the post. (á)

Posted: Tue Sep 16, 2003 9:18 am
by SantaGhost
try

Code: Select all

content="text/html; charset=iso-8859-1"
what kind of rubbish is printed?

what where the original characters that became rubbish?

Posted: Wed Sep 17, 2003 11:23 am
by zemanel752
I've tried that, doesn't work...

if I write this:
á ó é
(a acute, o acute, e acute),
it appears like this:

á ó é

Posted: Wed Sep 17, 2003 3:33 pm
by m3rajk
that's becasue you're picking it up in one character set and reading it in another.


make sure it' sent int he same one used to display.

or send as html and use the HTML shorts (&#aacute;) instead of ascii


i actually had this problem with something before, so i'm about 99% sure you're sending it in a diff character set than you're picking it up in but not converting between them. for my purposes, since i had several people using different displays i was able to pick up on that beig the actual problem (and becasue it displayed right for me) and found the easiest thing to do was to convert to html shorts and that worked.

Posted: Thu Sep 18, 2003 2:34 am
by zemanel752
I'm sending it using a flash movie, I'll have a look at it. thanks for the tip

Posted: Thu Sep 18, 2003 2:15 pm
by m3rajk
no problem. like i said, i think i was in your shoes once, and ifi'm right then i just happend to luck out because the issue was showing itself in a way that made the actual problem quite clear and the solution (initially char set conversion) was an issue so i asked a friend that pionted me to an easier solution, now i'm pointing you there