Hi guys just wondering why my code display header as auth_username instead of declared variable
function sanitize_my_email($field) {
$field = filter_var($field, FILTER_SANITIZE_EMAIL);
if (filter_var($field, FILTER_VALIDATE_EMAIL)) {
return true;
} else {
return false;
}
}
$to_email = 'la.gelo.fernandez@gmail.com';
$from = 'angelo.roccatech@gmail.com';
$subject = 'Testing PHP Mail';
$message = 'This mail is sent using the PHP mail ';
$headers = "" .
"Reply-To:" . $from . "\r\n" .
"From:" . $from . "\r\n" .
"X-Mailer: PHP/" . phpversion();
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
//check if the email address is invalid $secure_check
$secure_check = sanitize_my_email($to_email);
if ($secure_check == false) {
echo "Invalid input";
} else { //send email
mail($to_email, $subject, $message, $headers);
echo "This email is sent using PHP Mail";
}
here's my output
from: la.gelo.fernandez@gmail.com // this one is my auth_username instead of angelo.roccatech@gmail.com reply-to: angelo.roccatech@gmail.com to: la.gelo.fernandez@gmail.com date: Mar 9, 2021, 12:56 PM subject: Testing PHP Mail