无法在 php 邮件中显示法语口音
我有以下 php 脚本根据返回的参数发送一封电子邮件:
<?
header('Content-Type: application/json; charset=utf-8');
$headers = "From: Source\r\n";
$headers .= "Content-type: text/html;charset=utf-8\r\n";
$to = $data["t_email"];
$subject = "Hello";
$message = (gather_post("locale") == "fr_CA")?"message français ééààèè": "english message";
mail($to, $subject, $message, $headers);
?>
我已经取出了不相关的部分。消息将正常发送,但重音符号将无法正确显示。一切都已设置为 utf-8 字符集,我不明白为什么这不起作用。
I have the following php script sends an email based on parameters returned:
<?
header('Content-Type: application/json; charset=utf-8');
$headers = "From: Source\r\n";
$headers .= "Content-type: text/html;charset=utf-8\r\n";
$to = $data["t_email"];
$subject = "Hello";
$message = (gather_post("locale") == "fr_CA")?"message français ééààèè": "english message";
mail($to, $subject, $message, $headers);
?>
I've taken parts out that are not relevent. The message will be sent out fine, but the accents will not appear correctly. Everything has been set as utf-8 charset, i don't understand why this isn't working.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可能需要使用 utf8_encode() 对 html 进行编码。例如:
我必须这样做才能动态导入法语 Word 文档,而且效果很好。如果这可以解决您的问题,请告诉我。
更新(示例工作代码)
You may have to encode the html with utf8_encode(). For example:
I have had to do this to dynamically import French Word docs, and it works great. Let me know if this solves your problem.
UPDATE (example working code)
要解决您的问题,您需要将以下行添加到发送电子邮件功能:
以下是此行与电子邮件功能的集成:
To resolve your issue you need to add the following line to your send email function:
Here is the integration of this line with an emailing function:
请参阅这里我发现的好评论。只有这个对我有用。
https://ncona.com /2011/06/using-utf-8-characters-on-an-e-mail-subject/
详细信息:
See here good comments I found. Only this works for me.
https://ncona.com/2011/06/using-utf-8-characters-on-an-e-mail-subject/
Details: