From 8a67529d0358af8b1c72f53c2ca6441c75be836d Mon Sep 17 00:00:00 2001 From: marcinzelent Date: Thu, 30 Nov 2017 11:30:10 +0100 Subject: Added sending e-mails test. --- .idea/php.xml | 2 +- .idea/pollution-sensor.iml | 94 --------- .idea/workspace.xml | 272 +++++++++++++++++++------ app/Resources/views/emails/registration.php | 6 + app/config/config.yml | 2 +- app/config/parameters.yml.dist | 19 -- src/AppBundle/Controller/NewDataController.php | 36 +++- 7 files changed, 255 insertions(+), 176 deletions(-) create mode 100644 app/Resources/views/emails/registration.php delete mode 100644 app/config/parameters.yml.dist diff --git a/.idea/php.xml b/.idea/php.xml index 50580b1..10d798a 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -42,5 +42,5 @@ - + \ No newline at end of file diff --git a/.idea/pollution-sensor.iml b/.idea/pollution-sensor.iml index bf2d349..2df1551 100644 --- a/.idea/pollution-sensor.iml +++ b/.idea/pollution-sensor.iml @@ -45,99 +45,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 2cf848a..99597d9 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -2,7 +2,13 @@ - + + + + + + + @@ -114,7 +152,7 @@ true DEFINITION_ORDER - + @@ -178,38 +216,52 @@ + - - + + - - + + - - + + - - + + + + + + + + + + + + + + + - - + + - - + + @@ -219,13 +271,12 @@ - - + - - + - + - - + + - - + + @@ -305,6 +358,98 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -328,7 +473,6 @@ - @@ -344,7 +488,6 @@ - @@ -352,7 +495,6 @@ - @@ -360,7 +502,6 @@ - @@ -368,7 +509,6 @@ - @@ -398,7 +538,6 @@ - @@ -406,7 +545,6 @@ - @@ -414,29 +552,20 @@ - - - - - - - - - + - - + @@ -454,14 +583,29 @@ + + + + + + + + + + + + + + + - - + + @@ -471,8 +615,8 @@ - - + + @@ -480,18 +624,26 @@ - + - - + + - + - - + + + + + + + + + + diff --git a/app/Resources/views/emails/registration.php b/app/Resources/views/emails/registration.php new file mode 100644 index 0000000..c2ac995 --- /dev/null +++ b/app/Resources/views/emails/registration.php @@ -0,0 +1,6 @@ +{# app/Resources/views/Emails/registration.html.twig #} +

You did it! You registered!

+ +Hi {{ name }}! You're successfully registered. + +Thanks! \ No newline at end of file diff --git a/app/config/config.yml b/app/config/config.yml index 1a5c147..4819c20 100644 --- a/app/config/config.yml +++ b/app/config/config.yml @@ -51,7 +51,7 @@ doctrine: # if using pdo_sqlite as your database driver: # 1. add the path in parameters.yml # e.g. database_path: '%kernel.project_dir%/var/data/data.sqlite' - # 2. Uncomment database_path in parameters.yml.dist + # 2. Uncomment database_path in parameters.yml # 3. Uncomment next line: #path: '%database_path%' diff --git a/app/config/parameters.yml.dist b/app/config/parameters.yml.dist deleted file mode 100644 index 2c20ddc..0000000 --- a/app/config/parameters.yml.dist +++ /dev/null @@ -1,19 +0,0 @@ -# This file is a "template" of what your parameters.yml file should look like -# Set parameters here that may be different on each deployment target of the app, e.g. development, staging, production. -# https://symfony.com/doc/current/best_practices/configuration.html#infrastructure-related-configuration -parameters: - database_host: 127.0.0.1 - database_port: ~ - database_name: symfony - database_user: root - database_password: ~ - # You should uncomment this if you want to use pdo_sqlite - #database_path: '%kernel.project_dir%/var/data/data.sqlite' - - mailer_transport: smtp - mailer_host: 127.0.0.1 - mailer_user: ~ - mailer_password: ~ - - # A secret key that's used to generate certain security-related tokens - secret: ThisTokenIsNotSoSecretChangeIt diff --git a/src/AppBundle/Controller/NewDataController.php b/src/AppBundle/Controller/NewDataController.php index 2e083d9..b6ed181 100644 --- a/src/AppBundle/Controller/NewDataController.php +++ b/src/AppBundle/Controller/NewDataController.php @@ -12,7 +12,6 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route; use Symfony\Component\HttpFoundation\Response; use Symfony\Bundle\FrameworkBundle\Controller\Controller; - class NewDataController extends Controller { /** @@ -38,8 +37,43 @@ class NewDataController extends Controller $response = new Response($data); $response->headers->set('Content-Type', 'application/json'); + $this->sendEmail("Marcin"); + return $response; } + public function sendEmail($name) + { + $message = (new \Swift_Message('Hello Email')) + ->setFrom('***REMOVED***') + ->setTo('***REMOVED***@edu.easj.dk') + ->setBody( + $this->renderView( + // app/Resources/views/Emails/registration.html.twig + 'Emails/registration.html.twig', + array('name' => $name) + ), + 'text/html' + ) + /* + * If you also want to include a plaintext version of the message + ->addPart( + $this->renderView( + 'Emails/registration.txt.twig', + array('name' => $name) + ), + 'text/plain' + ) + */ + ; + + //$mailer->send($message); + + // or, you can also fetch the mailer service this way + $this->get('mailer')->send($message); + + return $this->render(...); + } + } -- cgit v1.2.3