不在PHP发送电子邮件

时间:2017-02-03 06:11:09

标签: php

不使用php在网络服务中发送电子邮件。

代码如下,请检查并提出改变。

 <?php

   $con=mysqli_connect("localhost","root","","database");

   if(isset($_POST) & !empty($_POST)){

      $email = mysqli_real_escape_string($con, $_POST['email']);
      $mail=$_POST['mail'];
      $sql = "SELECT * FROM user WHERE email = '$email'";
      $res = mysqli_query($con, $sql);
      $count = mysqli_num_rows($res);
      if($count == 1){
            $r = mysqli_fetch_assoc($res);
            $password = $r['password'];
            $to = $r['email'];
            $subject = "Your Recovered Password";
            $message = "Please use this password to login " .$password ;
            $headers = "From : vivek@codingcyber.com";
            $m=mail($to, $subject, $message, $headers, "-f ".$email);       
            if($m){
                echo "Your Password has been sent to your email id";
            }
            else{
                echo "Failed to Recover your password, try again";
            }

      }
    else{
            echo "User name does not exist in database";
    }
   }
 mysqli_close($con);

?>

1 个答案:

答案 0 :(得分:0)

v <- union(v1, v2)
Filter(function(x) length(grep(x, v))==1, v)
# [1] "ab"      "bc"      "cd"      "ef"      "sm"      "ez-de"   "yolo-da"

结帐此链接mail()函数