Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function indexAction()
- {
- $email = new Email();
- $form = $this->createForm(new EmailType(), $email);
- $request = $this->getRequest();
- if ($request->getMethod() == 'POST') {
- $form->bindRequest($request);
- if ($form->isValid()) {
- $email = $form->getData();
- $em = $this->getDoctrine()->getEntityManager();
- $em->persist($email);
- $em->flush();
- $message = \Swift_Message::newInstance()
- ->setSubject('Hello Email')
- ->setFrom('infos@mapannonces.com')
- ->setTo($email->getEmail())
- ->setBody($this->renderView('MapDemoBundle:Demo:email.txt.twig')) ;
- $this->get('mailer')->send($message);
- return $this->redirect( $this->generateUrl('MapDemoBundle_email') );
- }
- }
- return $this->render('MapDemoBundle:Demo:index.html.twig', array(
- 'form' => $form->createView()
- ));
- }
Add Comment
Please, Sign In to add comment