没有从我的PHP表单接收电子邮件

时间:2014-02-01 01:10:31

标签: php forms

我有一个HTML表单和一个PHP处理程序,但我没有收到表单应该发送的电子邮件。我已经搜了好几个小时,我无法弄明白。我刚开始使用php,所以非常感谢帮助,谢谢。继承我的代码。我出于安全原因更改了电子邮件地址。

<form action="formHandler.php" method="post">
      <div class="forForm first">
      <label for="namename" class="contactLabel">Name</label><br /><input placeholder="Name" class="editable" type="text" name="namename" id="namename"/>
      </div>
      <div class="forForm second">
      <label for="emailemail" class="contactLabel">Email</label><br /><input placeholder="Email" class="editable" type="email" name="emailemail" id="emailemail" required/>
      </div>
      <div id="surname">
      <label for="surnamesurname" class="contactLabel">Surname</label><br /><input type="text" value="Smith" class="editable" name="surnamesurname" id="surnamesurname" />
      </div>
      <div>
      <input id="submitBTN" type="submit"/>
      </div>
      </form>

和formHandler.php

<?php    
$surname = $_REQUEST['surnamesurname'];
    if($surname != "Smith") {
    echo "We encountered a problem, please try again later1.";
    }else{
    $myemail = 'email@email.com';
    $name = $_REQUEST['namename'];
    $email = $_REQUEST['emailemail'];
    $from = "oneandone.net";
    $to = "contactform@domain.co.uk";
    $subject = "New sign up!";
    $body = "Someone new has signed up: \n Name: $name \n Email: $email";
    $headers = "From: $from";
    $result = "mail($to,$subject,$body,$headers)";
    if(!$result){echo "your message was not sent";}
}
?>

谢谢

1 个答案:

答案 0 :(得分:7)

您没有发送电子邮件,而是在定义字符串

变化

$result = "mail($to,$subject,$body,$headers)";

$result = mail($to,$subject,$body,$headers);

你可能会有更多的运气!