Not Sending Email in web service using php. 
The code is below please check and suggest the kind changes.
 <?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);
?>
 
     
    