【问题标题】:XAMPP send mail [duplicate]XAMPP发送邮件[重复]
【发布时间】:2015-07-28 21:49:07
【问题描述】:

我有这个代码,如果他忘记了,它会通过电子邮件发送请求密码。它正在工作(没有错误),但我没有收到任何邮件。 我不知道该怎么办。

我试过这个: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>

【问题讨论】:

  • 你能告诉我们你的邮件日志吗?您在服务器上使用什么配置发送邮件?顺便说一句,MySql 已弃用,很快就会被删除。改用 mysqli 或更好的 PDO
  • PHP 邮件程序发送邮件很糟糕。使用邮件程序包,例如 swiftmailerpear mail

标签: php mysql email


【解决方案1】:

问题在于服务器配置而不是您的代码。试着看看这个: php-ini-sendmail-configuration-to-send-an-email-using-a-php-script

【讨论】:

    猜你喜欢
    • 2014-12-03
    • 2016-05-13
    • 2015-02-23
    • 2012-12-15
    • 2017-03-16
    • 2015-07-03
    • 1970-01-01
    • 1970-01-01
    • 2013-05-28
    相关资源
    最近更新 更多