发送和检查是否从localhost xampp发送邮件

时间:2017-07-03 08:58:03

标签: php xampp localhost sendmail forgot-password

这是我网站上“忘记密码”模块的代码。我想在部署到实时服务器之前检查xampp服务器,是否发送和接收邮件。目前它根本不起作用。我已经对php.ini和sendmail.ini进行了必要的更改。有人可以告诉我哪里出错了。

  <?php

    @session_start();

    require("includes/config.php");

    require("classes/Database.class.php"); 

    require("classes/security_functions.php"); 

    include('classes/ps_pagination.php');

    require_once('classes/validation.class.php');

    require("classes/site_functions.php");

    $obj    =   new validation();

    $db     =   new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE); 

    $sec    =   new security_functions($db);

    $fnc=new site_functions($db);

    $errmsg     =   '' ;

    $succmsg    =   '' ;

    if(isset($_POST['btnRecovery']))

    {



        $email          =   mysqli_real_escape_string($db->link_id,(trim($_POST['email'])));

    if(empty($email))

    {

           $errmsg .= 'Please Enter Email<br>';

    }



    if(!empty($email)){

        if (!preg_match('/^[-._a-zA-Z0-9]+@[a-zA-Z0-9-._]+\\.[a-zA-Z]{2,4}$/', $email) || strlen($email) < 8 || strlen($email) > 100)

          $errmsg .= 'Please Enter Valid Email ID<br>';

    }



    $check1= $fnc->fieldTocheckPassword("tbl_user","email",$email, 3);

    if(!empty($check1))

    {

        $errmsg .= 'Please Enter your registered Email ID<br>';

    }

    if(empty($check1))

    {

        $password1  =   time()+rand(0, 9) ;

        $password   =   md5($password1) ;

        $res = mysqli_query($db->link_id,"UPDATE tbl_user SET password = '$password', raw_password='$password1'  WHERE email = '$email' AND type = 3");





    $msg = '<table width="600" style="border:solid; color:#006200;">

    <tr><td colspan="3" align="left">Dear User, <br>

    Your Login Details are as given below:</td></tr>

    <tr><td>Login Id:</td><td>:</td><td>'.$email.' </td></tr>

    <tr><td>Password:</td><td>:</td><td>'.$password1.' </td></tr>

    <tr><td style="height:40px;" colspan="3"></td></tr>

    <tr><td colspan="3">Team</td></tr>

    <tr><td colspan="3">AAFM</td></tr>





    <tr><td style="height:40px;" colspan="3"></td></tr>

    <tr><td colspan="3">Note: We recommend you to please reset your password while login.</td></tr>

    </table>';

    $subject    =   "Password Recovery from AAFM";

    $headers ='MIME-Version: 1.0' . "\r\n".

    'Content-type: text/html; charset=iso-8859-1' . "\r\n".

    'From: no-reply@aafm.com"\r\n"' .

    'Reply-To: ravinsoam@gmail.com' . "\r\n" .

    'X-Mailer: PHP/' . phpversion();
    ini_set('smtp_port',587);
    mail($email, $subject, $msg, $headers) ;

    $succmsg    =   "Please Check you Email.<br>Password has been send on your email id.<br>Please check your inbox/ spam folder." ;



    }

    }

    ?>

    <!DOCTYPE html>

    <html>

    <head>

    <!-- Meta -->

    <title>AAFM</title>

    <!-- CSS -->

    <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,300,400,600,700,800' rel='stylesheet' type='text/css'>

    <link rel="stylesheet" type="text/css" href="engine1/style.css" />

    <link rel="stylesheet" type="text/css" href="css/hover.css" />

    <script type="text/javascript" src="engine1/jquery.js"></script>

    </head>

    <body>

    <!-- Start WOWSlider.com BODY section -->

    <div id="wowslider-cover">&nbsp;</div>

    <div id="wowslider-container1">

      <div class="ws_images">

        <ul>

          <li><img src="data1/images/01.jpg" alt="167160841" title="167160841" id="wows1_1"/></li>

          <li><img src="data1/images/02.jpg" alt="101698382" title="101698382" id="wows1_2"/></li>

          <li><img src="data1/images/03.jpg" alt="146820126" title="146820126" id="wows1_3"/></li>



        </ul>

      </div>

      <span class="wsl"><a href="http://wowslider.com">DHTML Slideshow</a> by WOWSlider.com v5.2</span>

      <div class="ws_shadow"></div>

    </div>

    <script type="text/javascript" src="engine1/wowslider.js"></script>

    <script type="text/javascript" src="engine1/script.js"></script>

    <!-- End WOWSlider.com BODY section -->





    <form action="" method="post">

      <div class="loginPanel">

        <div class="loginPanelContent FormDiv">

          <div class="div_1_of_1"><img src="images/logo-1.png"></div>

          <!--<div class="div_1_of_1 LH1">My Payroll Online</div>-->



          <div class="div_1_of_1"><div class="error">



    <?php

    if($errmsg !="")

    {

     echo ucwords($errmsg );

    } 

    ?> 

    <?php

    if($succmsg !="")

    {

     echo ucwords($succmsg );

    } 

    ?> </div>

            <input type="text" placeholder="Email" name="email" required="email" id="username">

          </div>



          <div class="div_1_of_1" style=" margin-bottom:0;">

            <ul class="loginUl">

              <li><input name="btnRecovery" type="submit" class="button curl-top-right2" style="width:100%" value="Submit" /></li>

              <li><a href="index.php" id="registration" class="button curl-top-right2" style="width:100%">Existing User ?</a></li>

              </ul>

              <div class="div_1_of_1" style="display:none;">

              <a href="registration.php" class="button curl-top-right2" style="width: 190px;margin-top: 10px;">Forgot Password ?</a>

            </div>

          </div>

        </div>

      </div>

    </form>

    <!-- Footer -->

    <div id="footer" class="clearfix">&copy; 2016 - AAFM India - All Rights Reserved.</div>

    <!-- /Footer -->

    </div>

    <script language="javascript" type="text/javascript">

    $(document).ready( function() {

        $('#ForgotPassword').click( function() {

            if( !$("#username").val() ) { alert("Please enter your username!") }

            else { alert("Password has been sent to your email address!") }

        });

    });

    </script>

    </body>

    </html>

1 个答案:

答案 0 :(得分:1)

您的XAMP配置是什么?

默认情况下,文件xampp\sendmail\sendmail.ini包含行

smtp_server=mail.mydomain.com

您需要更改为

smtp_server=localhost