0

Using mail() function i can send one email without a problem. But when i try to send a second email I receive the first but not the second.

$s1 = mail("info1@domain.com", $subject, $message, $headers);
$s2 = mail("info2@domain.com", $subject, $message, $headers);
$s3 = $s1 && $s2;

And $s3 is TRUE. I have tried sending two email in one mail call:

mail("info1@domain.com, info2@domain.com", $subject, $message, $headers);

Still only the first is sent but not the second. How i can solve it? Of course the email addresses are all valid and none are in spam folders.

Matt S
  • 14,976
  • 6
  • 57
  • 76
Marcello Impastato
  • 2,263
  • 5
  • 30
  • 52
  • 2
    the question's too unclear and pseudo code just doesn't hold much water – Funk Forty Niner Aug 11 '17 at 14:02
  • The problem not is about code, becouse all it work fine with one only email. Just only when i try to add a second email, then are problem. But if need i can update it, of course. Was just for understand from what depend it. – Marcello Impastato Aug 11 '17 at 14:05
  • There are far too many duplicates for this. Here are a few https://stackoverflow.com/questions/12708997/php-form-send-email-to-multiple-recipients --- https://stackoverflow.com/questions/4506078/php-send-mail-to-multiple-email-addresses and your post does not contain enough code to support the problem. – Funk Forty Niner Aug 11 '17 at 14:10

2 Answers2

0

I did not understand your question, but if you want to send email to multiple users, then try this,

$recipients = [
    'email1@emai.com',
    'email2@emai.com',
];
$recipients = implode(',', $recipients); // your email address
mail($recipients, $email_subject, $msg);
0

Not really sure how have you added your headers but try and add this while declaring headers:

$headers .= 'Cc: info2@domain.com' . "\r\n";

so copying the email to the 2nd email address.

Just_Do_It
  • 821
  • 7
  • 20