Update email validation to return false for invalid addresses

Fix email validation to properly handle invalid addresses by returning
false
This commit is contained in:
Ruben 2026-01-14 20:25:59 +01:00
parent b1f19e2cdd
commit fd1f152e55

View file

@ -613,9 +613,10 @@ class PHPMailerLite
{
if (!empty($str) && is_string($str)) {
preg_match('/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,9}/', $str, $bk);
if (!empty($bk[0])) {
$email = $bk[0];
if (empty($bk[0])) {
return false;
}
$email = $bk[0];
$email = str_ireplace(["\r", "\n", "\t", '"', ",", "<", ">"], "", $email);
if (filter_var($email, FILTER_VALIDATE_EMAIL) && self::IsValidEmail($email)) {
return $email;