duanmangxie7131 2014-10-08 11:34
浏览 49

php xampp邮件未发送[重复]

This question already has an answer here:

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?

</div>
  • 写回答

1条回答 默认 最新

  • douqian1296 2014-10-08 11:38
    关注

    It won't work on localhost. Try it on a free hosting website and it will work.

    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line