Chinese Characters in email sent via PHP not showing up.
Posted
by rye
on Stack Overflow
See other posts from Stack Overflow
or by rye
Published on 2010-04-02T11:46:30Z
Indexed on
2010/04/06
8:43 UTC
Read the original article
Hit count: 228
hi All,
a funny problem. I send mail via PHP from my testing server with Chinese chars in it and it sends perfectly. Encoding is utf-8. When I upload the same PHP file to another server and try to send from there, the e-mail will look 90% fine in one mail client (web-based mail actually, gmail), but in my mail client (Apple Mail) it's all gibberish even when I try changing the encoding in the mail client.
I'm stuck here because everything works fine on one server, but not on another so I'm not sure where to start looking for solutions. What's even more puzzling is that on the production server, the mail looks somewhat ok (strange case of some characters not showing) but in other mail apps it looks like garbage.
any idea where I can start looking to solve this?
thanks for any help here!
Regards..
php script
$books = json_decode ($_POST['books']);
$body = '
?? ' . $_POST['name'] . ',?????????,????????,????????
'; $iLen = count($books); for ($i = 0; $i ' . $book->title . '
' . $book->author . '
'; $body .= '??: ' . $book->synopsis . '
'; $body .= '???: ' . $book->age . '
'; $body .= '??: ' . $book->setting . '
'; $body .= '??: ' . $book->purpose . '
'; $body .= '???: ' . $book->call . '
'; $body .= '???: ' . $book->publisher . '
'; } $body .= ' ????,
Name
';
$headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $headers .= 'From: Name ' . "\r\n";
$ok = mail ($_POST['email'], '???????:???????????', $body, $headers);
result
ä? å¥? ryan,
以丗æ?¯ä? ä»/å–œä’ ç?Œç«?,ç»?å–©å–?è®”æ??亗è¯=稗,昕蜙æ±?ç°=䒜籟å?ŸåŸ?
ç‘?ç‘?ævŒæ?˜å¤°çv±ä? 麜å?—å¸8é?·å°p, å±±å§?
Synopsis: ç?—å?¯çv±ç°=å°?å?‰å®?å®?æ•/ä’v牨å®8痬瘒ç°=戒åp?å‚‘å?‰åœvåœv说å®8æ?˜å¤°çv±å®8ã•? Age Group: 4 - 6 å”™ Setting: ç=¤ä?„ Purpose: ä»·å•pè§?å‚‘ä¿8è¿?五å–?ç°=æ=ƒæ8? Call no: JP MAC
Publisher: 麜å?—å¸8é?·å°p, å±±å§?. ç‘?ç‘?ævŒæ?˜å¤°çv±ä? .丅海 : 尌咴å=¿ç«¥åOºç˜vç¤=, 2005.
© Stack Overflow or respective owner