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.

Note: You should also use the setTo() method when you want to perform a batchSend() to deliver the message to each recipient separately without exposing all of the addresses. In this scenario Swift Mailer performs some internal transformations on the message during the sending process.
Note: Multiple calls to setTo() will not add new recipients – each call overrides the previous calls. If you want to iteratively add recipients, use the addTo() method.
//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');

NOTE: Documentation for version 3 is in the wiki.