PHP配置SMTP使用mail函数发送邮件报错求助
PHP mail函数结合SMTP发送邮件报错排查求助
我尝试使用PHP的mail函数结合SMTP配置给自己发送邮件,但出现报错:
我使用的代码如下:
function notify_password($username, $password) { // notify the user that their password has been changed $conn = db_connect(); $result = $conn->query("select email from user where username='".$username."'"); if (!$result) { throw new Exception('Could not find email address.'); } else if ($result->num_rows == 0) { throw new Exception('Could not find email address.'); // username not in db } else { $row = $result->fetch_object(); $email = $row->email; $from = "From: di@gmail.com \r\n"; $mesg = "Your password has been changed to ".$password."\r\n" ."Please change it next time you log in.\r\n"; if (mail($email, 'login information', $mesg, $from)) { return true; } else { throw new Exception('Could not send email.'); } } }
我的php.ini文件配置如下:
sendmail文件配置如下:
请帮忙排查问题。
内容的提问来源于stack exchange,提问作者Dimitris Lisg
相关产品推荐
相关产品推荐

