From 7d09b3a6201a175128421d117d4c63495813fa05 Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Fri, 1 Dec 2017 11:06:29 +0100 Subject: Refactored sending of e-mails and made it work. --- src/AppBundle/Utils/EmailSender.php | 42 +++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 src/AppBundle/Utils/EmailSender.php (limited to 'src/AppBundle/Utils/EmailSender.php') diff --git a/src/AppBundle/Utils/EmailSender.php b/src/AppBundle/Utils/EmailSender.php new file mode 100644 index 0000000..e6f74c2 --- /dev/null +++ b/src/AppBundle/Utils/EmailSender.php @@ -0,0 +1,42 @@ +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); + } +} \ No newline at end of file -- cgit v1.2.3