dqhnp44220 2018-05-31 17:49
浏览 116
已采纳

PHP mail()无法在消息内容中找到重音符号的解决方案

I have tried many solutions proposed about it, but still can't find the one that works. The email is sent succesfully but accents are in html code.

This is my code for the email content :

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

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

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

        //Message section
        //$message = utf8_decode($message);
        $message_hed_APPLICATION_RECEIVER ="

--{$mime_boundary}
";
        $message_hed_APPLICATION_RECEIVER .="Content-Type: text/plain; charset=\"UTF-8\"
";
        $message_hed_APPLICATION_RECEIVER .="Content-Transfer-Encoding: 8bit

" . $message . "

";
        $message_hed_APPLICATION_RECEIVER .= "--{$mime_boundary}
";

The content of $message displayed by var_dump is "sfdféèî" but the email message content I receive is : sfdf&eacute;&egrave;&icirc;. Can someone help me with that? I have tried utf8_decode() and many other propositions on forums but still it ain't working. Thanks for your help guys.

  • 写回答

1条回答 默认 最新

  • dongsu1951 2018-05-31 18:00
    关注

    If you view the source of the page you will see that your string actually does contain the html entities. var_dump() will have hinted at this being the case like so:

    string(27) "sfdféèî"
    

    You can convert the entities back to UTF8 with:

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

    Which yields:

    string(10) "sfdféèî"
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)
  • ¥65 抖音咸鱼付款链接转码支付宝
  • ¥15 ubuntu22.04上安装ursim-3.15.8.106339遇到的问题
  • ¥15 blast算法(相关搜索:数据库)
  • ¥15 请问有人会紧聚焦相关的matlab知识嘛?
  • ¥15 网络通信安全解决方案
  • ¥50 yalmip+Gurobi