Mail function in PHP does not allow me to send email to multiple recipients

I am trying to send emails to a team and some invited individuals to indicate their assigned cooperation. However, only the first recipient (the team) in the $to seems to be receiving an email. The invited individuals do not receive any emails. Can anyone tell what I did wrong?

<?php

/* Template Name: send emails */

include_once ('important.php');

function get_emails($campus) {    
global $mydb;

    $individuals = array();    
    $individuals = $mydb->get_results("SELECT * FROM individuals WHERE campus = '$campus'");

    return array_map(function($e) {
    return $e->individual_email;   }, $individuals); 
}


$team_email = 'teamA@gmail.com'; 
$campus = 'NY'; 
$individuals = get_emails($campus); 
$to = $team_email. ', ' .implode(', ', $individuals);

$subject = 'Team invitation from ' . $team_email. '!';
$message = 'Hello everyone, you are now working together';
send_email($message, $subject, $to);

function send_email($message, $subject, $to, $from='admin@gmail.com', $from_name='Admin Team Creator') {   $message = '';

  $message .= '<html>';
    $message .= '<body>';
      $message .= $msg;
      $message .= '-<br/>';
      $message .= '<font face="tahoma, sans-serif" color="#0eafd6"><b>The Admin Team Creator</b></font><br/>';
    $message .= '</body>';   $message .= '</html>';

  $headers = '';   $headers .= 'MIME-Version: 1.0' . "rn";   $headers .= 'Content-Type: text/html; charset=iso-8859-1' . "rn";   $headers .= 'From: ' . $from . ' <' . $from_name . '>' . "rn" . 'Reply-To: ' . $from . "rn" . 'X-Mailer: PHP/' . phpversion();

  return mail($to, $subject, $message, $headers, '-f ' . $from); }

?>

Read more here: Mail function in PHP does not allow me to send email to multiple recipients

Leave a Reply

Your email address will not be published. Required fields are marked *