setUsername('***REMOVED***') ->setPassword('***REMOVED***') ; // Create the Mailer using your created Transport $mailer = new Swift_Mailer($transport); // Create a message $message = (new Swift_Message('Pollutometer warning ' . date('d/m/Y h:i:s'))) ->setFrom(['***REMOVED***' => 'Pollutometer']) ->setTo(['***REMOVED***@edu.easj.dk' => 'A name']) ->setBody($this->renderView( 'emails/warning.html.twig', $data), 'text/html') ; // Send the message $result = $mailer->send($message); } }