Php邮件不发送邮件
我试图用下面的php脚本发送邮件,但邮件无法通过…脚本一直运行到最后,但没有发送邮件, 如果正在发送邮件,调试的最佳方法是什么Php邮件不发送邮件,php,email,Php,Email,我试图用下面的php脚本发送邮件,但邮件无法通过…脚本一直运行到最后,但没有发送邮件, 如果正在发送邮件,调试的最佳方法是什么 $link = $this->db_connection(); $enc_password = md5($password); //checking if the username is available in the table $result = mysqli_query($link, "SELECT con
$link = $this->db_connection();
$enc_password = md5($password);
//checking if the username is available in the table
$result = mysqli_query($link, "SELECT concat(users.title,' ',users.f_name,' ',users.s_name,' ',users.o_name) as fullname, user_id,user_name,role_id,status from users WHERE email='$emailusername' or user_name='$emailusername' and password='$enc_password'");
$user_data = mysqli_fetch_array($result, MYSQLI_BOTH);
$count_row = mysqli_num_rows($result);
$base_url = $this->url();
if ($count_row == 1) {
if ($password === "123456") {
//set the random id length
$random_id_length = 10;
$today = date("Y-m-d H:i:s");
//generate a random id encrypt it and store it in $rnd_id
$rnd_id = crypt(uniqid($today, 1));
//to remove any slashes that might have come
$rnd_id = strip_tags(stripslashes($rnd_id));
//Removing any . or / and reversing the string
$rnd_id = str_replace(".", "", $rnd_id);
$rnd_id = strrev(str_replace("/", "", $rnd_id));
//finally I take the first 10 characters from the $rnd_id
$random_key = substr($rnd_id, 0, $random_id_length);
$email = $user_data['email'];
$username = $user_data['username'];
$user_id = $user_data['user_id'];
$full_name = $user_data['fullname'];
$headers = "From: webmaster@emarps.org" . "\r\n" .
"CC: harrisdindisamuel@gmail.com";
$subject = "Reset User Account Password";
// the message
$msg = '
---------------------
Hey :' . $full_name . '!
<fieldset>
We currently received a request for resetting your EMARPS ACCOUNT Password. You can reset your Personal Account Password
through the link below:
<hr>
------------------------
Please click this link to activate your account:<a href="' . $base_url . 'resetpassword.php?uq=/' . $random_key . '">Reset</a>
------------------------ ';
;
// use wordwrap() if lines are longer than 70 characters
// $msg = wordwrap($msg, 70);
// send email
mail($email, $subject, $msg, $headers);
}
确定邮件功能是否正常工作/邮件是否通过的最佳方法是什么?使用简单的if语句:
if(mail($email, $subject, $msg, $headers)) {
echo 'Mail send!';
}
如果邮件已成功接受传递,则返回TRUE,返回FALSE
否则
重要的是要注意,仅仅因为邮件被接受
但这并不意味着邮件将实际到达预定的目的地
目的地
您只能检查邮件服务器是否将邮件排除在外,而不能检查邮件是否确实已送达。您只能在您的邮件服务器mailq中检查这种情况,或者使用所有退回邮件的返回邮件地址检查该收件箱。这有点复杂。首先,看看返回的内容,看看函数是否正常工作。应该返回true。安装了什么软件在您的环境中发送电子邮件?