我有这个代码,如果他忘了密码就会通过电子邮件发送请求密码。它工作(没有错误),但我没有收到任何邮件。 我不知道该怎么做。
我试过这个:XAMPP Sendmail using Gmail account但同样。
<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>
答案 0 :(得分:0)
问题在于服务器配置而不是代码。试着看看这个: php-ini-sendmail-configuration-to-send-an-email-using-a-php-script