0

I am using symfony 2.1 and I have form for adding e-mails (with table in Database).Something like Newsletter. And i want to send group email for all recipents from this table. How to put all this email`s from database table into setTo.

$message = \Swift_Message::newInstance()
                    ->setSubject('Hello Email')
                    ->setFrom('form@form.pl')
                    ->setTo('??')
                    ->setBody(
                        $this->renderView(
                            'NewAdminBundle:Msg:index.html.twig',
                            array('singlelist' => $list

                          )
                        )
                    )
                ;
                $this->get('mailer')->send($message);
Cre3k
  • 327
  • 5
  • 20

1 Answers1

1

You can pass an array to the setTo() method:

  setTo(
       array(
         'receiver@domain.org',
         'other@domain.org' => 'A name'
    ))

See also http://swiftmailer.org/docs/messages.html

Asieh hojatoleslami
  • 3,240
  • 7
  • 31
  • 45
Veve
  • 6,643
  • 5
  • 39
  • 58
  • OK, but I want to use there a variable from base with emails list. – Cre3k Sep 24 '14 at 11:15
  • @Cre3k you can use an array you previously made with your database contacts, then pass it to the 'setTo' method. – Veve Sep 24 '14 at 14:10