I am trying to send an confirmation email after user makes an account. The email doesn't send anything. I did test it and the email is not even going to the spam or inbox folder. Am I missing something? Thank you for your help.
$status = "";
if (isset($_POST["sign_up"])) {
$first_name = (isset($_POST['first_name']) ? $_POST['first_name'] : null);
$last_name = (isset($_POST['last_name']) ? $_POST['last_name'] : null);
$username = (isset($_POST['username']) ? $_POST['username'] : null);
$password = (isset($_POST['password']) ? $_POST['password'] : null);
$email = (isset($_POST['email']) ? $_POST['email'] : null);
$phone = (isset($_POST['phone']) ? $_POST['phone'] : null);
if ($first_name == "" || $last_name == "" || $username == "" || $password == "" || $email == "" || $phone == "") {
$status = '<p style="color:#FF0000;">Please fill out all the field';
} else if (strlen($password) < 6) {
$status = '<p style="color:#FF0000;">Password must more than 6 characters';
} else{
$sql = "INSERT INTO members(
first_name,
last_name,
username,
password,
email,
phone
) VALUES (
'$first_name',
'$last_name',
'$username',
'$password',
'$email',
'$phone'
)";
$res = mysqli_query($mysqli,$sql) or die(mysqli_error());
if ($res) {
$to = $email;
$subject = "Confirmation from Yu Fong to $username";
$from = "abc@yahoo.com";
$message = "Please click the link below to verify and activate your account. \r\n";
$message .= "Testing";
$header = "From: " .$from. "\r\n";
$header .="Reply-To: ".$from. "\r\n";
$header .= "CC: abc@yahoo.com\r\n";
$header .= "Return-Path: ".$from. "\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
$header .= "X-Priority: 3\r\n";
$header .= "X-Mailer: PHP". phpversion() ."\r\n";
$sentmail = mail($to, $subject, $message, $header);
if ($sentmail == true) {
echo $status = '<p style="color:#FF0000;">Congratulations! Your account has been created. An confirmation email has been sent!';
} else {
echo "Eror!";
}
}
}
}