在我的PHP表单上使用西里尔文有问题
当有人用西里尔文给我发电子邮件时,我收到了一些奇怪的信件。这是我的一部分: HTML代码:在我的PHP表单上使用西里尔文有问题,php,html,Php,Html,当有人用西里尔文给我发电子邮件时,我收到了一些奇怪的信件。这是我的一部分: HTML代码: <form method="post" action="index.php" id="formaa" accept-charset="UTF-8"> <input name="name" placeholder="Name" id="aa"> <input name="email" type="email" placeholder="E-mail" id="
<form method="post" action="index.php" id="formaa" accept-charset="UTF-8">
<input name="name" placeholder="Name" id="aa">
<input name="email" type="email" placeholder="E-mail" id="aa">
<textarea name="message" placeholder="Message"></textarea>
<input name="human" placeholder="2+2=" id="ab">
<input id="submit" name="submit" type="submit" value="Submit">
</form>
PHP(全文):
请更改:
$from = 'From: PappuLighting';
到
和变化:
if (mail ($to, $subject, $body, $from)) {
致:
替换
$from='from:papplighting'代码>至$headers='From:papplighting'
另外if(邮件($to,$subject,$body,$from))
toif(邮件($to,$subject,$body,$headers))
从中检查邮件函数的示例代码
$message=”
HTML电子邮件
此电子邮件包含HTML标记
名字
姓氏
约翰
雌鹿
";
//发送HTML电子邮件时始终设置内容类型
$headers=“MIME版本:1.0”。“\r\n”;
$headers.=“内容类型:text/html;字符集=UTF-8”。“\r\n”;
//更多标题
$headers.='From:'。“\r\n”;
$headers.='Cc:myboss@example.com' . “\r\n”;
邮件($to、$subject、$message、$headers);
?>
您已在$header变量中设置了2个标题,但这些标题未在邮件函数中使用。未做任何更改:/change to:$headers=“MIME Version:1.0”。“\r\n”$标题。=“内容类型:文本/html;字符集=UTF-8”。“\r\n”;那有帮助!非常感谢。
$headers = 'From: PappuLighting';
if (mail ($to, $subject, $body, $from)) {
if (mail ($to, $subject, $body, $headers)) {
$message = "
<html>
<head>
<title>HTML email</title>
</head>
<body>
<p>This email contains HTML Tags!</p>
<table>
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr>
<td>John</td>
<td>Doe</td>
</tr>
</table>
</body>
</html>
";
// Always set content-type when sending HTML email
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: <webmaster@example.com>' . "\r\n";
$headers .= 'Cc: myboss@example.com' . "\r\n";
mail($to,$subject,$message,$headers);
?>