doushang8512 2010-04-02 11:46
浏览 69

通过PHP发送的电子邮件中的中文字符未显示

I send mail via PHP with Chinese characters from my testing server, and it sends it out perfectly. The encoding is UTF-8. When I upload the same PHP file to another server and try to send e-mail from there, it will look 90% fine in one mail client (web-based mail actually, GMail), but in another 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 another. I'm not sure where to start looking for solutions. What's even more puzzling is that on the production server, the e-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?

PHP

$books = json_decode ($_POST['books']);

$body = '
<body bgcolor="#999999"><center>
<table width="700" border="0" cellspacing="2" cellpadding="10" bgcolor="#FFFFFF">
<tr>
    <td>
    你好 ' . $_POST['name'] . ',<br/><br/>以下是你从学习网站,给孩子讲故事课程,所要求的书籍名单<br/><br/><hr noshade="noshade" />
    </td>
</tr>
<tr>
<td>';

$iLen = count($books);
for ($i = 0; $i < $iLen; $i = $i + 1) {
    $book = $books[$i];

    $body .= '<b>' . $book->title . '</b><br/>' . $book->author . '<br/><br/>';
    $body .= '简介: ' . $book->synopsis . '<br/>';
    $body .= '年龄层: ' . $book->age . '<br/>';
    $body .= '场景: ' . $book->setting . '<br/>';
    $body .= '目的: ' . $book->purpose . '<br/>';
    $body .= '索书号: ' . $book->call . '<br/><br/>';
    $body .= '出版商: ' . $book->publisher . '<br/><br/><hr noshade="noshade" />';

}

$body .= '
</td>
</tr>
<tr>
    <td>
    亲切问侯,<br/>Name
    </td>
</tr>
</table>
</center>
</body>
';

$headers  = 'MIME-Version: 1.0' . "
";
$headers .= 'Content-type: text/html; charset=utf-8' . "
";
$headers .= 'From: Name <no-reply@here.com>' . "
";

$ok = mail ($_POST['email'], '讲故事给孩子听:您所要求的故事精选书单', $body, $headers);

Result

ä∏ å¥∏ ryan,

ä»¥ä¸—æ˘¯ä∏ ä»⁄å–œä’ ç∏Œç«˙,ç»˙å–©å–∆è®”æ∑亗è¯≤稗,æ≈•èœ™æ±≠ç˚≥䒜籟å∆ŸåŸ

瑲瑲æ√Œæ˛≈å¤˚ç√±ä∏ 
麜å∑—å¸∞é˝·å°π, å±±å§∫ 

Synopsis: 粗å∂¯ç√±ç˚≥å°∂å∑‰å®ˇå®ˇæ•⁄ä’√牨å®∞ç—¬ç≈’ç˚≥戒åπ∂å‚‘å∑‰åœ√åœ√说å®∞æ˛≈å¤˚ç√±å®∞ã•≠
Age Group: 4 - 6 å”™
Setting: ç≤¤ä∏„
Purpose: ä»·å•πè§≠å‚‘ä¿∞è¿˝äº”å–∆ç˚≥æ≥ƒæ∞∑
Call no: JP MAC

Publisher: 麜å∑—å¸∞é˝·å°π, å±±å§∫. 瑲瑲æ√Œæ˛≈å¤˚ç√±ä∏ .丅海 : 尌咴å≥¿ç«¥åΩºç≈√ç¤≤, 2005.
  • 写回答

3条回答 默认 最新

  • doupingzhi9674 2010-04-07 02:08
    关注

    maybe you should encode your message in MIME format

    评论

报告相同问题?

悬赏问题

  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面