0

I have a question about php mail() function.
This function allows multiple recipients that separated by comma, for example:
$mailto="a@test.com,b@test.com,c@test.com";
mail($mailto,$subject,$message,$headers);

If all recipients address are correct, no problem, mail can be sent properly.
However if one address is no longer valid (for instance he leave company), this mail function then failed, those who have valid email address cannot receive email.

Is there a way to skip invalid address and let valid ones still receive email?

Any advice?

3
Contributors
2
Replies
12
Views
5 Years
Discussion Span
Last Post by minitauros
0

am sorry michael123 but i doubt you can skip such validation as we cannot connect to the D.B of the email service providers and because of that we cannot know who is and who isn't registered hope this helps

0

Are you sure that mail() doesn't send anything at all if one recipient's email is invalid?

If so, you could maybe use a loop to send separate mails to every email address in an array? E.g.:

$email_addresses = array(
    'email1@email.com',
    'email2@email.com',
    // etc.
);

// Fill these in with whatever you want.
$subject = '';
$message = '';
$headers = '';

// Send the emails.
foreach($email_addresses as $email)
{
    mail($email, $subject, $message, $headers);
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.