2014-10-08 118 views
0

我想實現使用php郵件功能忘記密碼功能。php xampp郵件沒有發送

我使用的XAMPP和Mac OS 10.9.4

我得到response1並沒有錯誤消息了。但郵件沒有發送。

以下是代碼:

<?php 
// error_reporting(E_ALL); 
$response = array(); 
require_once __DIR__.'/db_connect.php'; 
$db = new DB_CONNECT(); 
if(isset($_POST['email'])){ 
    $to = $_POST['email']; 
    $subject = "Password recovery"; 
    $res = mysql_query("select password from userMaster where email_id = '$to'"); 
    if($res){ 
     $pwd=""; 
     while($row=mysql_fetch_array($res)){ 
      $pwd = $row['password']; 
      // echo $pwd." ".$to; 
     } 
     $result = mail($to, $subject,$pwd); 
     echo $result; die; 
     if($result){ 
      $response["success"]=1; 
      $response["message"]="Mail sent successfully"; 
     } else { 
      print_r(error_get_last()); echo $result; die; 
     } 
    }else { 
     $response["success"] = 0; 
     $response["message"] = "Error sending mail"; 
     //echo mysql_error(); die; 
    } 
}else { 
    $response["success"] = 0; 
    $response["message"] = "Missing parameters"; 
} 
echo json_encode($response); 
?> 

我用Google搜索,發現了一些解決方案,但沒有對我有利的工作。 我哪裏錯了?我該如何解決這個問題?

回答

0

它不會在本地主機上工作。嘗試在免費的託管網站上,它會起作用。