title: can not send email to own domain, but can for other domain like as gmail
body: <p>I want to send a new password by email when a user forgets their password to login to my site. The email fails to send unless it's a Gmail address. Can anyone explain what the problem is?</p>
  
  <pre><code>&lt;?php
  $email_address=$_POST['email_to'];
  $tbl_name=user;
  
  $query="SELECT * FROM user WHERE email = '$email_address'";
  $st=mysql_query($query);
  $recs=mysql_num_rows($st);
  
  if ($recs == 0)
  {
      echo "&lt;center&gt;&lt;font face='Verdana' size='2' color=red&gt;&lt;b&gt;No Password&lt;/b&gt;&lt;br&gt; Sorry Your address is not there in our database . You can signup and login to use our site. &lt;BR&gt;&lt;BR&gt;       &lt;/center&gt;";
      exit;
  }
  
  
  if ($recs == 1){
  function makeRandomPassword() 
  {
  $salt = "abchefghjkmnpqrstuvwxyz0123456789";
  srand((double)microtime()*1000000);
  $i = 0;
  while ($i &lt;= 7) 
  {
  $num = rand() % 33;
  $tmp = substr($salt, $num, 1);
  $pass = $pass . $tmp;
     $i++;
  }
     return $pass;
  }
  
  $random_password = makeRandomPassword();
  $db_password = md5($random_password);
  
  $sql = mysql_query("UPDATE user SET   password='$db_password',display_pass='$random_password'  WHERE email='$email_address'");
  
  echo "New Password has been send to your email.";
  echo "&lt;a href='index.php'&gt;Back&lt;/a&gt;";
  
  //------- SEND MAIL FORM --------
  
  $to=$email_address;
  $subject="Your password here";
  
  $header="from: Admin Ayam Kampung Lingnan &lt;your email&gt;";
  
  // Your message
  $messages= "Password Anda untuk login ke website Lingnan \r\n";
  $messages.="Password Anda Adalah: $random_password \r\n";
  $messages.="Mohon untuk tidak di balas, karena ini adalah email otomatis \r\n";
  
  // send email
  $sentmail = mail($to,$subject,$messages,$header);
  
  }
  }
  ?&gt;
  </code></pre>