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 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?