Guest User

Untitled

a guest
Apr 26th, 2018
535
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. /**
  2. * @Route("testmail", name="testmail")
  3. */
  4. public function testmail(Request $request)
  5. {
  6.  
  7. $societe = null;
  8. $form = $this->createFormBuilder()
  9. ->add('Societe', TextType::class, array('label' => 'Société'), array('constraints' => array(new NotBlank(array()),
  10. new Length(array('min' => 2,
  11. 'max' => 25)))))
  12. -> add('send',SubmitType::class, array('label' => 'Cotation'))
  13.  
  14. ->getForm();
  15.  
  16. $form->handleRequest($request);
  17.  
  18. if ($form->isValid()) {
  19. if ($request->isMethod('POST')) {
  20. $societe = $form["Societe"]->getData();
  21.  
  22. $message = Swift_Message::newInstance()
  23. ->setSubject('Etude Financiere')
  24. ->setFrom('wolffvianney@gmail.com')
  25. ->setTo('vianney.wolff@yahoo.fr')
  26. ->setCharset('utf-8')
  27. ->setContentType('text/html')
  28. ->setBody($this->render('@gkeep/Finance/email.html.twig', array('Societe' => $societe)));
  29.  
  30. $this->get('mailer')->send($message);
  31.  
  32.  
  33. }
  34. }
  35.  
  36. return $this->render('@gkeep/Finance/finance.html.twig', array('form' =>$form->createView(),
  37. 'Societe'=>$societe));
  38.  
  39.  
  40. }
  41.  
  42. swiftmailer:
  43. transport: '%mailer_transport%'
  44. host: '%mailer_host%'
  45. username: '%mailer_user%'
  46. password: '%mailer_password%'
  47. spool: { type: memory }
  48.  
  49. mailer_transport: mail
  50. mailer_host: smtp.gmail.com
  51. mailer_user: wolffvianney@gmail.com
  52. mailer_password: *mypasswordforwolffvianney@gmail.com*
  53. secret: thesecret
  54.  
  55. <html>
  56. hi
  57. société : {{ Societe }}
  58. </html>
Add Comment
Please, Sign In to add comment