php无法通过php邮件功能接收邮件

时间:2017-10-04 07:19:09

标签: php

我是php的新手我希望通过php邮件功能向用户发送邮件我已经编写了代码但是没有工作的邮件没有收到。我在localhost xamp服务器上测试它是我的代码。

        <?php include "connection.php";

 if(isset($_POST) & !empty($_POST)){
//print_r($_POST); die;
   $username = mysqli_real_escape_string($conn, $_POST['username']);
   $sql = "SELECT * FROM `users` WHERE username = '$username'";
   $res = mysqli_query($conn, $sql);
   $count = mysqli_num_rows($res);
   if($count == 1){
    echo "Send email to user with password";
   }else{
        echo "User name does not exist in database";
    }

   $r = mysqli_fetch_assoc($res);
     $password = $r['password'];
   $to = $r['username'];
    $subject = "Your Recovered Password";

   $message = "Please use this password to login " . $password;
       $headers = "From :abc23@gmail.com";
      if(mail($to, $subject, $message, $headers)){
        echo "Your Password has been sent to your email id";
       }else{
       echo "Failed to Recover your password, try again";

         } 

        }


     ?> 

0 个答案:

没有答案