无法接收表单信息邮件

时间:2014-03-17 07:38:00

标签: php html

我正在尝试将联系表单字段中的详细信息发送到我的邮件ID。我点击时似乎没有任何错误 提交,但我没有收到任何邮件。

这是我的代码

<?PHP
$email = $_POST["email"];
$to = "myemail@example.com";
$subject = "New Email Address for Mailing List";
$headers = "From: $email\n";
$message = "A visitor to your site has sent the following details to you.\n
Name : $name
Email Address: $email
Phone number: $phone
Message: $message";
$user = "$email";
$usersubject = "Thank You";
$userheaders = "From: myemail@example.com\n";
$usermessage = "Thank you for contacting us.";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);
?>

<form id="contact-form" class="contact-form" action="contact-form-info.php" enctype="text/plain" >
<div id="result" class="result"></div>
<input type="text" name="name" id="name" placeholder="Name *">
<input type="text" name="email" id="email" placeholder="E-mail *">
<input type="text" name="phone" id="phone" placeholder="Phone *" onChange="PhoneValidation(this)" ;>
<textarea cols="5" rows="5" name="message" id="message" placeholder="Message *"></textarea>
<input type="submit" class="btn-dark" value="SEND">

1 个答案:

答案 0 :(得分:0)

您的表格是:

  • 将数据编码为text/plain,这不是机器可读的
  • 将数据发送为GET而不是POST(这是您要阅读的内容)

删除enctype属性并添加method="POST"

您也永远不会将值分配给$name$phone