mail send with different charset

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
zemanel752
Forum Newbie
Posts: 4
Joined: Mon Sep 15, 2003 7:15 am

mail send with different charset

Post 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 
"); 
?>
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post 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 (á)
User avatar
SantaGhost
Forum Commoner
Posts: 41
Joined: Mon Sep 15, 2003 11:54 am

Post by SantaGhost »

you might wanna take a look at the charset (dont know if portuguese is different)
zemanel752
Forum Newbie
Posts: 4
Joined: Mon Sep 15, 2003 7:15 am

Post 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. (á)
User avatar
SantaGhost
Forum Commoner
Posts: 41
Joined: Mon Sep 15, 2003 11:54 am

Post 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?
zemanel752
Forum Newbie
Posts: 4
Joined: Mon Sep 15, 2003 7:15 am

Post by zemanel752 »

I've tried that, doesn't work...

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

á ó é
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post 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.
zemanel752
Forum Newbie
Posts: 4
Joined: Mon Sep 15, 2003 7:15 am

Post by zemanel752 »

I'm sending it using a flash movie, I'll have a look at it. thanks for the tip
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post 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
Post Reply