dtt2012 2013-05-14 12:49
浏览 54
已采纳

如何在swift邮件程序setTo函数中传递二维数组值

I am getting a 2 dimensional array value as a result after a for loop.The value is $chunk[$i][$j].And when I passed that value into setTo function, the error showing as

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.

How do I solve this?.Here my code

$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();
      }
   } 
  • 写回答

1条回答 默认 最新

  • doushan6692 2013-05-14 20:28
    关注

    I think you are overthinking this.

    Have you looked at the documentation on how to send batch emails WITHOUT recipients being aware of each other? In your snippet each email contains up to 10 recipients, which may be better then sending all recipients, but still is pretty bad.

    Have a look at Sending emails in batch and also at the plugins to make sure you don't reach the limit of emails you are allowed to send in a certain time frame.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序