PHP发送邮件,解决乱码

<?php  

     $to = "429517385@qq.com";  

      $date = date("Y年m月d日");  

     $header  = 'MIME-Version: 1.0' . "\r\n";    

$header .= 'Content-type: text/html; charset=utf-8' . "\r\n"; 

   $header .= "To: $to \r\n";    $header .= 'From: 624159864@qq.com' . "\r\n";   

    $mailsubject  = "=?UTF-8?B?".base64_encode($mailsubject)."?=";

$mailsubject  = "绿尔雅减肥茶订单"; 

$user = $_POST['name'];

$qq = $_POST['email'];

$shouji = $_POST['shouji'];

$number = $_POST['number'];

$address = $_POST['address'];

$contents = $_POST['content'];   

 $content = '客户'."$user".'<br />';   

 $content .= '<br />';     

$content .= '订购了'."$number!".'<br />';   

 $content .= '联系电话:'."$shouji".'<br />'; 

$content .= '联系QQ:'."$qq".'<br />';

  $content .= '收货地址:'."$address".'<br />'; 

$content .= '客户留言:'."$contents".'<br />';    

    $content .= "$date".'<br />'; 

ini_set("mbstring.language", "Neutral");

ini_set("mbstring.internal_encoding", "UTF-8");

ini_set("mbstring.http_input", "UTF-8");

ini_set("mbstring.http_output", "UTF-8");

ini_set("mbstring.encoding_translation", "On");

ini_set("mbstring.detect_order", "auto");

ini_set("mbstring.substitute_character", "long");  

 $result = mail($to, $mailsubject, $content, $headers);       

 if($result)    {        echo '订购成功!';    }

?> 

posted @ 2011-06-11 10:13  唐岗  阅读(...)  评论(...编辑  收藏