Setting To: Recipients
To: recipients are required in a message and are set with the setTo() or addTo() methods of the message.
To set To: recipients, create the message object using either new Swift_Message( ... ) or Swift_Message::newInstance( ... ), then call the setTo() method with a complete array of addresses, or use the addTo() method to iteratively add recipients.
The setTo() method accepts input in various formats as described in the chapter, Addresses in Swift Mailer. The addTo() method takes either one or two parameters. The first being the email address and the second optional parameter being the name of the recipient.
To: recipients are visible in the message headers and will be seen by the other recipients.
//Using setTo() to set all recipients in one go
$message->setTo(array(
'person1@example.org',
'person2@otherdomain.org' => 'Person 2 Name',
'person3@example.org',
'person4@example.org',
'person5@example.org' => 'Person 5 Name'
));
//Using addTo() to add recipients iteratively
$message->addTo('person1@example.org');
$message->addTo('person2@example.org', 'Person 2 Name');