我提出了一些相关的问题,但我不够清楚。我正在通过html表单发送电子邮件。使用此代码时,我发送标题和来自wrk,但没有消息正文。这是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>
这是我的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); ?>
我只是不知道问题是什么。先感谢您。所有帮助表示赞赏 -Ben
答案 0 :(得分:1)
这段代码对我来说很好。我对您的代码进行了少量修改。请试试。无论如何,您的代码的流程都不正确。
<?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>
干杯!