2012-02-01 61 views
2

我正在構建一個小應用程序,通過電子郵件將我的「2do」列表內容發送到Evernote。對於消息正文,字符顯示正確,但對於主題,字符會混亂。這是PHP代碼:PHP - 帶有阿拉伯字符的電子郵件

主要PHP:

$subject  = $_POST["thesubject"]; 

    $bound_text=md5(uniqid(time())); 
    $headers.="MIME-Version: 1.0\r\n" . "Content-Type: multipart/mixed; boundary=\"PHP-mixed-$bound_text\"\r\n"; 

    $message="--PHP-mixed-$bound_text\r\n"  
       ."Content-Type: text/html; charset=\"utf-8\"\r\n" 
       ."Content-Transfer-Encoding: 7bit\r\n\r\n" 
       ."<html><head></head><body>" 
       ."<div style=\"font-family: Arial, Helvetica, sans-serif; font-size : 1.3em; color: #000000;width: 100%;text-align: left;\">$text_message</div></body></html>\r\n\r\n" 
       ."--PHP-mixed-$bound_text\r\n" 
       ."Content-Transfer-Encoding: base64\r\n" 
       ."Content-Disposition: attachment; filename=\"$attachment\"\r\n" 
    ."Content-Type: image/jpeg; name=\"$attachment\"\r\n\r\n" 
    .chunk_split($file) 
      ."\r\n\r\n" 
       ."--PHP-mixed-$bound_text--\r\n\r\n"; 

    } 

The mail part: 

    $subject_evernote = utf8_decode($subject); 
    mail($evernote,$subject_evernote,$message,$headers); 

有什麼不對呢?

+0

剛剛得到[phpmailer](http://phpmailer.worxware.com/)並開心 – zerkms 2012-02-01 01:39:20

+0

'$ subject'在哪裏? – 2012-02-01 01:41:27

回答

3
mb_internal_encoding("UTF-8"); 

$subject_evernote = mb_encode_mimeheader("العربية"); 
3

電子郵件標題包含主題,只能包含ASCII字符。因此,您將不得不對MIME編碼非ASCII字符,以符合該要求。看看mb_encode_mimeheader