Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP在线表单未发送到Gmail_Php_Html_Forms_Http Post - Fatal编程技术网

PHP在线表单未发送到Gmail

PHP在线表单未发送到Gmail,php,html,forms,http-post,Php,Html,Forms,Http Post,问题是,当我提交这份表格时,它表明出了一些问题。有人能查一下我哪里出错了吗 HTML代码: <div class="main"> <div class="info">Give your feedback</div> <form action="mail.php" method="post" name="form" class="form-box"> <label for="name">Name</la

问题是,当我提交这份表格时,它表明出了一些问题。有人能查一下我哪里出错了吗

HTML代码:

  <div class="main">
   <div class="info">Give your feedback</div>
     <form action="mail.php" method="post" name="form" class="form-box">
     <label for="name">Name</label><br>
     <input type="text" name="name" class="inp" placeholder="Enter Your Name" required><br>
     <label for="email">Email</label><br>
     <input type="email" name="email" class="inp" placeholder="Enter Your Email" required><br>
     <label for="phone">Phone</label><br>
    <input type="tel" name="phone" class="inp" placeholder="Enter Your Phone" required><br>
     <input type="submit" name="submit" value="Send" class="sub-btn">
   </form>
 </div>

给出你的反馈
名称

电子邮件

电话

PHP代码

  <?php
     if(isset($_POST['submit'])){
      $name=$_POST['name'];
      $email=$_POST['email'];
      $phone=$_POST['phone'];
      $msg=$_POST['msg'];

      $to='onlyanivar@gmail.com';
      $subject='Form Submission';
      $message="Name:".$name."\n"."Phone:" .$phone. "\n"."Wrote the following: "."\n\n".$msg;

      if(mail($to, $subject, $message, $headers)){
          echo "<h1>Sent Successfully! Thank you"." ".$name.", We will contact you shortly</h1>";   
      }
      else{
          echo "Something went wrong!";
      }
  ?>


您在调用mail函数时没有声明$headers变量。

您在调用mail函数时没有声明$headers变量。

我认为
isset($\u POST)
应该足以检查表单是否已发布。您的意思是只需更改isset($\u POST)而不是isset$\u POST['submit']?是的,这就是我的意思。我认为
isset($\u POST)
应该足以检查表单是否已发布。你的意思是只需更改isset($\u POST)而不是isset$\u POST['submit']?是的,这就是我的意思。我删除了这个变量。但仍然存在问题我测试了你的代码,它可以正常工作(在“if”的末尾缺少一个braket)在mail.php中,除此之外,它还可以工作)。问题一定是来自你发送的服务器,gmail需要SPF和DKIM来正确地向你发送电子邮件。我删除了这个变量。但是Stil problemI测试了你的代码,它正常工作(除了正常工作之外,mail.php中的“if”结尾缺少一个braket)。问题一定是来自您发送的服务器,gmail需要SPF和DKIM才能正确地向您发送电子邮件。