title: Why is my php forget password not sending out the email
body: <p>The query wise is working fine, i can echo out the email address and the password associated to the username however when it states that the email is being sent out i still do not receive it in my mailbox. Any idea what went wrong?</p>
  
  <p>Here's my full code:</p>
  
  <pre><code>&lt;?php session_start();
  mysql_connect("localhost","root","");//database connection
  mysql_select_db("database");
  if (isset($_POST['username'])){
      $username = $_POST['username'];
      $query="select * from dbusers where username='$username'";
      $result   = mysql_query($query);
      $count=mysql_num_rows($result);
      // If the count is equal to one, we will send message other wise display an error message.
      if($count==1)
      {
          $rows=mysql_fetch_array($result);
          $pass  =  $rows['password'];//FETCHING PASS
          echo "your pass is ::".($pass)."";
          $to = $rows['email'];
          echo "your email is ::".$to;
          //Details for sending E-mail
          $from = "Your Password details";
          $url = "http://localhost.com";
          $body  =  "Reset Password
          -----------------------------------------------
          Url : $url;
          email Details is : $to;
          Here is your password  : $pass;
          Sincerely,
          Coding Cyber";
          $from = "admin@support.com";
          $subject = "Here's your new password";
          $headers1 = "From: $from\n";
          $sentmail = mail ( $to, $subject, $body, $headers1 );
      } else {
      if ($_POST ['username'] != "") {
      echo "No such username found!&lt;/span&gt;";
          }
          }
      //If the message is sent successfully, display sucess message otherwise display an error message.
      if($sentmail==1)
      {
          echo "&lt;span style='color: #ff0000;'&gt; Your Password Has Been Sent To Your Email Address.&lt;/span&gt;";
      }
          else
          {
          if($_POST['username']!="")
          echo "&lt;span style='color: #ff0000;'&gt; Cannot send password to your e-mail address.Problem with sending mail...&lt;/span&gt;";
      }
  }
  ?&gt;
  
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;
  &lt;title&gt;Home: Webpage&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form action="" method="post"&gt;
          &lt;label&gt; Enter your User ID : &lt;/label&gt;
          &lt;input id="username" type="text" name="username" /&gt;
          &lt;input id="button" type="submit" name="button" value="Submit" /&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>