From e6f78e954131188d8d28a0367680e4333cf70185 Mon Sep 17 00:00:00 2001 From: Kayn Ty Date: Mon, 14 May 2018 13:15:45 +0200 Subject: [PATCH] test mail route --- .../views/default/test-email.html.twig | 7 ++++++ app/config/routing.yml | 4 ++++ .../Controller/DefaultController.php | 22 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 app/Resources/views/default/test-email.html.twig diff --git a/app/Resources/views/default/test-email.html.twig b/app/Resources/views/default/test-email.html.twig new file mode 100644 index 00000000..d93f6ad5 --- /dev/null +++ b/app/Resources/views/default/test-email.html.twig @@ -0,0 +1,7 @@ +{% extends 'base.html.twig' %} + +{% block bigMain %} +

tadam test de mail

+ le contenu + Lorem ipsum dolor sit amet, consectetur adipisicing elit. Accusamus doloremque exercitationem provident quae quod soluta sunt velit. Architecto, assumenda deserunt expedita laudantium nemo voluptatem. Atque commodi est iste itaque mollitia. Consequatur cumque cupiditate eveniet facilis illo illum impedit itaque omnis placeat quaerat, quia quidem ratione saepe similique sunt veniam veritatis. +{% endblock %} diff --git a/app/config/routing.yml b/app/config/routing.yml index 4090140e..ff574633 100755 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -50,3 +50,7 @@ add_selling: fos_user: resource: "@FOSUserBundle/Resources/config/routing/all.xml" +# emails +tktest_mail: + path: /test-email + defaults: { _controller: AppBundle:Default:email } diff --git a/src/AppBundle/Controller/DefaultController.php b/src/AppBundle/Controller/DefaultController.php index 5a1fdc4d..7d4d7647 100755 --- a/src/AppBundle/Controller/DefaultController.php +++ b/src/AppBundle/Controller/DefaultController.php @@ -73,6 +73,28 @@ class DefaultController extends Controller { ] ); } + + /** + * envoyer un email + */ + public function emailAction() { + $name = "noble barbare"; + $message = \Swift_Message::newInstance() + ->setSubject( 'Hello Email' ) + ->setFrom( 'test-symfony-tykayn@meluzine.org' ) + ->setTo( 'tykayn@gmail.com' ) + ->setBody( $this->renderView( 'default/test-email.html.twig', + [ 'name' => $name ] ) ); + $this->get( 'mailer' )->send( $message ); + +//return 'yay test de mail'; + return $this->render( + 'default/test-email.html.twig', + [ + ] + ); + } + /** * get user products * @return JsonResponse