$message = new Swift_Message(); $message->setTo('example@example.com');
$message = (new Swift_Message()) ->setSubject('Test Email') ->setFrom('sender@example.com') ->setTo(['recipient1@example.com', 'recipient2@example.com']) ->setBody('This is a test email.');In this example, a new instance of the Swift_Message class is created, and various methods are called to set the subject, sender email address, recipient email addresses, and body for the email message. The setTo method is passed an array of recipient email addresses to set multiple recipients for the email message. Overall, the PHP Swift_Message setTo method is a powerful tool used for setting the recipient email address for email messages sent via the Swift Mailer package library.