我正在构建一个小应用程序,通过电子邮件将我的“2do”列表内容发送到Evernote。对于消息正文,正确显示字符,但对于主题,字符会混乱。这是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 :(得分:3)
包含主题的电子邮件标题只能包含ASCII字符。因此,您必须对非ASCII字符进行MIME编码,以使其符合该要求。看看mb_encode_mimeheader
。
答案 1 :(得分:3)
mb_internal_encoding("UTF-8");
$subject_evernote = mb_encode_mimeheader("العربية");