[英]PHP email not working, message not in email body
I had put up a few questions related but i wasn't clear enough. 我提出了一些有关的问题,但我还不够清楚。 I am sending an email through an html form.
我正在通过html表单发送电子邮件。 With this code when I send it the title and from wrk, but there is no message body.
使用此代码时,我将其标题发送给wrk,但没有消息正文。 Here is the html:
这是html:
<html> <body><form method="post" action="contact.php">
Email: <input name="email" type="text"><br> name:<br>
<textarea name="name" rows="15" cols="40"></textarea><br>
Message:<br> <textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit"> </form> <body> <html>
Here is my PHP: 这是我的PHP:
<?php
$headers=
"BCC: " . $_POST['email'];
$headers .= "BCC: ".$to_visitor."\r\n";
$headers .= "From: Your Company <your_company@example.com>\r\n";
$header1 = " ";
$header2 = " ";
$to_visitor = $_POST["email"];
$common_data = $_POST["message"];
$thank_you = " ".$common_data;
mail($to_visitor, "Your Memory", $thank_you, $header2); ?>
I just don't know what the problem is. 我只是不知道问题是什么。 Thank you in advance.
先感谢您。 All help is appreciated -Ben
感谢所有帮助-本
This code works fine for me. 这段代码对我来说很好用。 I did small modifications to your code.
我对您的代码做了一些小的修改。 Please try.
请试试。 Your code is not in correct flow anyway.
无论如何,您的代码流程不正确。
<?php
if(isset($_POST['email']))
{
$headers = "From: Your Company <your_company@example.com>\r\n";
$to_visitor = $_POST["email"];
$common_data = $_POST["message"];
mail($to_visitor, "Your Memory", $common_data, $headers);
} ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<html> <body><form method="post" >
Email: <input name="email" type="text"><br> name:<br>
<textarea name="name" rows="15" cols="40"></textarea><br>
Message:<br> <textarea name="message" rows="15" cols="40"></textarea><br>
<input type="submit"> </form> <body> <html>
</body>
</html>
Cheers! 干杯!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.