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

  • 写回答

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!

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ yoloV5改写遇到的问题
  • ¥20 win11修改中文用户名路径
  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?