aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarcinzelent <zelent.marcin@gmail.com>2017-11-30 11:30:10 +0100
committermarcinzelent <zelent.marcin@gmail.com>2017-11-30 11:30:10 +0100
commit8a67529d0358af8b1c72f53c2ca6441c75be836d (patch)
tree98e97b50c97f7762f205078a2090e587044edc60 /src/AppBundle/Controller
parent56cb58fdabf883a5641bfdb7d897f7b7dde2eb74 (diff)
Added sending e-mails test.
Diffstat (limited to 'src/AppBundle/Controller')
-rw-r--r--src/AppBundle/Controller/NewDataController.php36
1 files changed, 35 insertions, 1 deletions
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(...);
+ }
+
}