diff options
Diffstat (limited to 'src/AppBundle/Utils')
-rw-r--r-- | src/AppBundle/Utils/EmailSender.php | 42 |
1 files changed, 42 insertions, 0 deletions
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 @@ +<?php +/** + * Created by PhpStorm. + * User: marcin + * Date: 01/12/17 + * Time: 10:47 + */ + +namespace AppBundle\Utils; + +use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; +use Symfony\Bundle\FrameworkBundle\Controller\Controller; +use Swift_SmtpTransport; +use Swift_Mailer; +use Swift_Message; + +class EmailSender extends Controller +{ + public function sendEmail(array $data) + { +// Create the Transport + $transport = (new Swift_SmtpTransport('mail.cock.li', 465, 'ssl')) + ->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 |