PHP中的邮件功能不允许我向多个收件人发送电子邮件

时间:2017-04-08 17:31:01

标签: php mysql wordpress

我正在尝试向团队和一些受邀个人发送电子邮件,以表明他们指定的合作。但是,只有$to中的第一个收件人(团队)似乎正在接收电子邮件。受邀个人不会收到任何电子邮件。谁能说出我做错了什么?

<?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' . "\r\n";   $headers .= 'Content-Type: text/html; charset=iso-8859-1' . "\r\n";   $headers .= 'From: ' . $from . ' <' . $from_name . '>' . "\r\n" . 'Reply-To: ' . $from . "\r\n" . 'X-Mailer: PHP/' . phpversion();

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

?>

0 个答案:

没有答案