Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在php邮件中显示法语口音_Php_Email_Utf 8_Character Encoding_Iso - Fatal编程技术网

无法在php邮件中显示法语口音

无法在php邮件中显示法语口音,php,email,utf-8,character-encoding,iso,Php,Email,Utf 8,Character Encoding,Iso,我有以下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 = (ga

我有以下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字符集,我不明白这为什么不起作用。

您可能必须使用utf8\u encode()对html进行编码。例如:

$message = utf8_encode("message français ééààèè");
我必须这样做才能动态导入法语Word文档,而且效果很好。让我知道这是否解决了你的问题

更新(示例工作代码)
要解决您的问题,您需要在发送电子邮件功能中添加以下行:

$headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
function send_email($to,$subject,$message,$fromemail) {

    $headers = "From: $fromemail" . "\r\n";
    $headers .= "Return-Path: $fromemail" . "\r\n";
    $headers .= "Errors-To: $fromemail" . "\r\n";
    $headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
    @mail($to,$subject,$message,$fromemail);

}
以下是该行与电子邮件功能的集成:

$headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
function send_email($to,$subject,$message,$fromemail) {

    $headers = "From: $fromemail" . "\r\n";
    $headers .= "Return-Path: $fromemail" . "\r\n";
    $headers .= "Errors-To: $fromemail" . "\r\n";
    $headers .= 'Content-type: text/plain; charset=UTF-8' . "\r\n";
    @mail($to,$subject,$message,$fromemail);

}

在这里看到我发现的好评论。只有这个对我有用。

详情:

to = 'example@example.com';
$subject = 'Subject with non ASCII ó¿¡á';
$message = 'Message with non ASCII ó¿¡á';
$headers = 'From: example@example.com'."\r\n"
.'Content-Type: text/plain; charset=utf-8'."\r\n";
mail($to, '=?utf-8?B?'.base64_encode($subject).'?=', $message, $headers);

嗨,我试着添加utf8_编码,但它仍然没有给我的口音。我不知道我的问题是否在我的文档中的其他地方。我应该确保我的编码在其他任何地方都是正确的吗?据我所知,对于文本,utf8_编码就是您所需要的。我相信,如果您要从MySQL中提取数据,则必须运行一个不同的函数。我从来没有尝试过在电子邮件中发送法语字符。哦,好吧,我没有从我的数据库中提取任何数据。但是,我从$\u GET变量中提取了一些数据点。然而,这些数据点没有任何口音,我想知道它们是否仍然应该是utf-8编码的?嗯。我刚刚测试过,utf8_编码对我有效。也许这取决于您使用的电子邮件服务。我将用我的代码进行更新。@bozdoz有人能为java更新上面的示例吗?我在java中也有同样的问题