I am trying to send mail with the following php script but the mail is not going through ....the script runs to the end but no mail is sent, What is the best way to debug if the mail is being sent?
$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);
}
What is the best way to determine if the mail function is working/ if the mail is going through?