I'm trying to check if many e-mail addresses are correct in order to send them.
The thing is, while I filter with filter_var_array()
and FILTER_VALIDATE_EMAIL
, if only one is correct among all the mails, it still proceeds.
Here is my code:
$test_email_friend = explode(",", $email_friend);
if ( !filter_var_array($test_email_friend, FILTER_VALIDATE_EMAIL)) {
$errenvoi = "Please send only valid emails.";
}
else {
//message, headers etc here
if (mail($email_friend,$sujet,$message,$entete)){
$errenvoi = "Email sent !";
}
else {
$errenvoi = "Something very wrong happened, abandonship, I reapeat abandonship";
}
}
For example: If the array contain "test@test.com" and "unvalidmess". It's sent anyway, because one of the value is correct.
How can I fix this?
Thanks a lot