$transport = (new Swift_SmtpTransport($host, 465, 'ssl')
->setUsername($username)
->setPassword($password);
$mailer = new Swift_Mailer($transport);
$message = (new Swift_Message($subject))
->setFrom($from)
->setTo($to)
->setBody($text, "text/html");
$mailer->send($message);
$transport = new \Swift_Transport_SpoolTransport(
new \Swift_Events_SimpleEventDispatcher(),
new \Swift_FileSpool(__DIR__)
);
// Create the Mailer using your created Transport
$mailer = new \Swift_Mailer($transport);
// Create a message
$message = (new \Swift_Message('Wonderful Subject'))
->setFrom(['john@doe.com' => 'John Doe'])
->setTo(['receiver@domain.org', 'other@domain.org' => 'A name'])
->setBody('Here is the message itself')
;
// Send the message
$result = $mailer->send($message);