无法在php邮件中显示法语口音 [英] Cannot display french accents in php mail

查看:113
本文介绍了无法在php邮件中显示法语口音的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下php脚本根据返回的参数发送电子邮件:

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);
?>

我已经拿走了不相关的零件。该消息将被发送出去,但口音将不会正确显示。一切都设置为utf-8字符集,我不明白为什么这不工作。

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.

推荐答案

使用utf8_encode()对html进行编码。例如:

You may have to encode the html with utf8_encode(). For example:

$message = utf8_encode("message français ééààèè");

我不得不这样做来动态导入法语Word文档,它工作得很好。让我知道这是否解决了您的问题。

I have had to do this to dynamically import French Word docs, and it works great. Let me know if this solves your problem.

<?php
$to      = 'example@gmail.com';
$subject = 'subject';
$message = utf8_encode('message français ééààèè');
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

if(mail($to, $subject, $message, $headers)){
echo 'success!';
}
?>

这篇关于无法在php邮件中显示法语口音的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆