I am trying to implement forgot password feature using php mail feature.
I am using xampp and mac os 10.9.4
I get response
as 1
and there is no error message too. But the mail isn't sent.
Following is the code:
<?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);
?>
I googled and found a number of solutions but none worked in my favor. Where am I getting wrong? How do I solve this?