Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/286.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
电子邮件字符集。HTML电子邮件。PHP邮件_Php - Fatal编程技术网

电子邮件字符集。HTML电子邮件。PHP邮件

电子邮件字符集。HTML电子邮件。PHP邮件,php,Php,我发现正文消息中的php字符集有问题。邮件包含以下字符:žřà mycontact.php <?php //if "email" variable is filled out, send email if (isset($_REQUEST['email'])) { //Email information $admin_email = "mail@gmail.com"; $email = $_REQUEST['email']; $subject = 'Messag

我发现正文消息中的php字符集有问题。邮件包含以下字符:žřÃ

mycontact.php

<?php
//if "email" variable is filled out, send email
  if (isset($_REQUEST['email']))  {

  //Email information
  $admin_email = "mail@gmail.com";
  $email = $_REQUEST['email'];
  $subject = 'Message';
  $comment = $_REQUEST['comment'];



  //send email

  mail($admin_email, "$subject", $comment, "From:" . $email);

  //Email response
  echo "OK";
  }

  //if "email" variable is not filled out, display the form

  else  {
?>

 <form method="post">
  Email: <input name="email" type="text" /><br />
  Subject: <input name="subject" type="text" /><br />
  Message:<br />
  <textarea name="comment" rows="15" cols="40"></textarea><br />
  <input type="submit" value="Submit" />
  </form>

<?php
  }
?>

电子邮件:
主题:
消息:


请帮我做UTF8编码好吗?非常感谢

尝试使用php mailer类并告诉它:

$mail->CharSet='UTF-8';

$mail->Subject=utf8_encode("=?UTF-8?B?".base64_encode('you utf8 string')."?=");
或者,如果您不想使用php mailer类,您可以始终使用translate函数:

str_replace(
    array(,'¡','¿','á','é','í','ñ','ó','ú','Á','É','Í','Ñ','Ó','Ú'),
    array('&#161;','&#191;','&#225;','&#233;','&#237;','&#241;','&#243;','&#250;','&#193;','&#201;','&#205;','&#209;','&#211;','&#218;'),
    $yourstring
);

我的例子是一个拉丁(西班牙语)字母表,

尝试在表单上使用它来强制utf-8编码

<form method="post" action="/your/url/" accept-charset="UTF-8">

您是否尝试在脚本页面的标题中添加meta? 例如:


确保您在任何地方都使用了
UTF8

php**header()**

<?php header("Content-type: text/html; charset=utf-8"); ?>

请看-你的问题的标题应该是一个问题,而不是标签列表。我没有php邮件。在何处添加str_replace(数组(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,数组(,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,你的字符串);嗯,我没有帮我。同样的问题,电子邮件文本看起来像:Ä›ÄÄÄ™(我需要-ě,ě,ř,ž,ý,ý)脚本页是什么意思?我将meta添加到contact.php和form.php。但同样的问题,thx@user3719545您正在使用哪个Web服务器?
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />