PHP mail()找不到邮件内容重音的解决办法

PHP mail() can't find a solution for accents in message content

我已经尝试了很多关于它的解决方案,但仍然找不到有效的解决方案。电子邮件已成功发送,但重音符号在 html 代码中。

这是我的电子邮件内容代码:

        $to_APPLICATION_RECEIVER = "w@z.ca";
        $from_APPLICATION_RECEIVER = "x@y.com";
        $subject_APPLICATION_RECEIVER = "Subject";
        $headers_APPLICATION_RECEIVER = 'From: "people" <x@y.com> \r\n';
        $headers_APPLICATION_RECEIVER .= 'Reply-to: x@y.com \r\n';

        //define boundary
        $semi_rand = md5(time());
        $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";

        //tell header about $mime_boundary
        $headers_APPLICATION_RECEIVER .= "\nMIME-Version: 1.0\n";
        $headers_APPLICATION_RECEIVER .= "Content-Type: multipart/mixed;\n";
        $headers_APPLICATION_RECEIVER .= " boundary=\"{$mime_boundary}\"";

        //Message section
        //$message = utf8_decode($message);
        $message_hed_APPLICATION_RECEIVER ="\n\n--{$mime_boundary}\n";
        $message_hed_APPLICATION_RECEIVER .="Content-Type: text/plain; charset=\"UTF-8\"\n";
        $message_hed_APPLICATION_RECEIVER .="Content-Transfer-Encoding: 8bit\n\n" . $message . "\n\n";
        $message_hed_APPLICATION_RECEIVER .= "--{$mime_boundary}\n";

var_dump显示的$message内容是"sfdféèî",但我收到的邮件内容是:sfdf&eacute;&egrave;&icirc;。有人可以帮我吗?我在论坛上尝试了 utf8_decode() 和许多其他提议,但仍然没有用。谢谢你们的帮助。

如果您查看页面的 source,您将看到您的字符串实际上 包含 html 个实体。 var_dump() 会像这样暗示这种情况:

string(27) "sfdféèî"

您可以使用以下方法将实体转换回 UTF8:

html_entity_decode('sfdf&eacute;&egrave;&icirc;')

产生:

string(10) "sfdféèî"