我在for循环后得到一个二维数组值。值为$chunk[$i][$j]
。当我将该值传递给setTo函数时,
错误显示为
Warning: preg_match() expects parameter 2 to be string, array given in H:\xampp
\htdocs\sngmarket\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Mime\Headers
\MailboxHeader.php line 350
。
我该如何解决这个问题?。这是我的代码
$query = $em->createQuery("SELECT DISTINCT u.emailaddress FROM AcmeRegistrationBundle:userlist u");
$grp_emails[] = $query->getResult();
$chunk = array_chunk($grp_emails, 10);
$get_chunk_count = count($chunk);
for($i=0;$i<$get_chunk_count;$i++)
{
$count_inside_count = count($chunk[$i]);
for($j=0;$j<=$count_inside_count;$j++)
{
$mails=$chunk[$i][$j];
$message = \Swift_Message::newInstance()
->setSubject('Hello Email')
->setFrom('marketplace@socialnetgate.com')
->setTo($mails)
->setReturnPath('gowtham@ephronsystems.com')
->setBody('Hello World');
$this->get('mailer')->send($message);
return array();
}
}
答案 0 :(得分:0)
我认为你是在思考这个问题。
您是否查看了有关如何发送批量电子邮件但没有收件人彼此了解的文档?在您的代码段中,每封电子邮件最多包含10个收件人,这可能比发送所有收件人更好,但仍然非常糟糕。
请查看Sending emails in batch以及plugins,以确保您未达到允许在特定时间范围内发送的电子邮件的限制。