linux中的mail()函数使用lampp

时间:2017-01-24 11:39:35

标签: php xampp

我想用html和php创建一个反馈表单,我使用Xampp和linux mint作为操作系统。反馈表不会返回任何错误,但它既不发送任何邮件。请查看我的PHP代码。

<?php
$myemail  = "deepshikha@yahoo.com";
    if (isset($_GET['yourname']) && $_GET['yourname'] !== '  '){

    $yourname = $_GET['yourname'];
    }
    if (isset($_GET['subject']) && $_GET['subject'] !== '  '){

    $subject = $_GET['subject'];
    }
    if (isset($_GET['email']) && $_GET['email'] !== '  '){

    $email = $_GET['email'];
    }
    if (isset($_GET['website']) && $_GET['website'] !== '  '){

    $website = $_GET['website'];
    }
    if (isset($_GET['likeit']) && $_GET['likeit'] !== '  '){

    $likeit = $_GET['likeit'];
    }
    if (isset($_GET['comments']) && $_GET['comments'] !== '  '){

    $comments = $_GET['comments'];
    }
    if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
  {
show_error("E-mail address not valid");
 }
  if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
  {
    $website = '';
   }
   $message = "Hello!

   Your contact form has been submitted by:

  Name: $yourname
   E-mail: $email
   URL: $website

   Like the website? $likeit

  Comments:
  $comments

   End of message
   ";
  if(mail($myemail,$subject,$message)){
  header('Location: thanks.htm');
  }else{
 echo "Message could not be sent...";
  }
  exit();
   function check_input($data, $problem='')
   {
        $data = trim($data);
          $data = stripslashes($data);
           $data = htmlspecialchars($data);
         if ($problem && strlen($data) == 0)
           {
         show_error($problem);
           }
           return $data;
           }

         function show_error($myError)
        {
     ?>
     <html>
     <body>

     <b>Please correct the following error:</b><br />
     <?php echo $myError; ?>

     </body>
     </html>
   <?php
   exit();
   }
   ?>

我无法找到问题所在?如果有人可以提供帮助我会很感激。 如果需要,我也可以共享HTML代码。

1 个答案:

答案 0 :(得分:3)

这太复杂了 - 问题的根源是你实际上没有改变minimumInputLength,所以......它每次都会不断打印。

但是根据你的样本数据,这将做你想要的:

$V_name
相关问题