dtll2016
2014-02-01 01:10
浏览 43
已采纳

没有从我的PHP表单接收电子邮件[关闭]

i have a html form and a php handler, but i am not recieving the emails that the form should be sending. I have searched around for hours and i cant figure it out. I have just started using php so help is greatly appreciated, thank you. heres my code. i have changed the email addresses for security reasons.

<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>

and 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: 
 Name: $name 
 Email: $email";
    $headers = "From: $from";
    $result = "mail($to,$subject,$body,$headers)";
    if(!$result){echo "your message was not sent";}
}
?>

Thank you

图片转代码服务由CSDN问答提供 功能建议

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

 &lt; form action =“formHandler.php”method =“post”&gt; 
&lt; div class =“forForm 第一个“&gt; 
&lt; label for =”namename“class =”contactLabel“&gt;名称&lt; / label&gt;&lt; br /&gt;&lt; input placeholder =”Name“class =”editable“type =”text“  name =“namename”id =“namename”/&gt; 
&lt; / div&gt; 
&lt; div class =“forForm second”&gt; 
&lt; label for =“emailemail”class =“contactLabel”&gt; 电子邮件&lt; / label&gt;&lt; br /&gt;&lt; input placeholder =“Email”class =“editable”type =“email”name =“emailemail”id =“emailemail”required /&gt; 
&lt; / div&gt;  
&lt; div id =“surname”&gt; 
&lt; label for =“surnamesurname”class =“contactLabel”&gt; Surname&lt; / label&gt;&lt; br /&gt;&lt; input type =“text”value =  “Smith”class =“editable”name =“surnamesurname”id =“surnamesurname”/&gt; 
&lt; / div&gt; 
&lt; div&gt; 
&lt; input id =“submitBTN”type =“submit”/  &gt; 
&lt; / div&gt; 
&lt; / form&gt; 
   \  n 
 

和formHandler.php

 &lt;?php 
 $ surname = $ _REQUEST ['surnamesurname']; 
 if($ surname!=“  Smith“){
 echo”我们遇到了问题,请稍后再试1。“; 
} else {
 $ myemail ='email@email.com'; 
 $ name = $ _REQUEST ['namename']  ; 
 $ email = $ _REQUEST ['emailemail']; 
 $ from =“oneandone.net”; 
 $ to =“contactform@domain.co.uk”; 
 $ subject =“新注册!  “; 
 $ body =”有人新注册:
名称:$ name 
电子邮件:$ email“; 
 $ headers =”From:$ from“; 
 $ result =”mail($ to  ,$ subject,$ body,$ headers)“; 
 if(!$ result){echo”您的邮件未发送“;} 
} 
?&gt; 
   \  n 
 

谢谢

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • douji7399 2014-02-01 01:13
    已采纳

    You're not sending an email, you're defining a string

    change

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

    to

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

    And you might have more luck!

    打赏 评论

相关推荐 更多相似问题