0

I have this code which sends to request the password via email if he forgot it. It's working(no errors) but i dont receive any mails. I dont know what to do.

I tried this: XAMPP Sendmail using Gmail account but same.

<html>
<head>
<style type="text/css">
 input{
 border:1px solid olive;
 border-radius:5px;
 }
 h1{
  color:darkgreen;
  font-size:22px;
  text-align:center;
 }

</style>
</head>
<body>
<h1>Forgot Password<h1>
<form action='#' method='post'>
<table cellspacing='5' align='center'>
<tr><td>Email id:</td><td><input type='text' name='mail'/></td></tr>
<tr><td></td><td><input type='submit' name='submit' value='Submit'/></td></tr>
</table>
</form>

<?php
if(isset($_POST['submit']))
{ 
 mysql_connect('localhost','root','') or die(mysql_error());
 mysql_select_db('oes') or die(mysql_error());
 $mail=$_POST['mail'];
 $q=mysql_query("select * from student where emailid='".$mail."' ") or die(mysql_error());
 $p=mysql_affected_rows();
 if($p!=0) 
 {
  $res=mysql_fetch_array($q);
  $to=$res['emailid'];
  $subject='Remind password';
  $message='Your password : '.$res['stdpassword']; 
  $headers='From:octaenache@gmail.com';
  $m=mail($to,$subject,$message,$headers);
  if($m)
  {
    echo'Check your inbox in mail';
  }
  else
  {
   echo'mail is not send';
  }
 }
 else
 {
  echo'You entered mail id is not present';
 }
}
?>
</body>
</html>
Community
  • 1
  • 1
Octavian
  • 43
  • 5
  • can you show us your mail log? What configuration are you using on your server to send mail? BTW **MySql is deprecated** and will be soon removed. Use mysqli or better PDO instead – Lelio Faieta May 17 '15 at 10:37
  • PHP mailer is horrible for sending mails. Use mailer packages such as, `swiftmailer` or `pear mail`. – Bhavesh G May 17 '15 at 10:46

1 Answers1

0

The issue is rather in the server configuration than in your code. Try to look over this: php-ini-sendmail-configuration-to-send-an-email-using-a-php-script

Community
  • 1
  • 1