/**
  * This method is called right after the post is stored in the database during the Form submit.
  * It checks whether the form has a notification email set, and if so, it sends out a notification
  * email.
  *
  * @param FormSubmitEvent $event
  */
 public function postFormSubmit(FormSubmitEvent $event)
 {
     $post = $event->getPost();
     $form = $post->getForm();
     if (!$form->getNotificationEmail()) {
         return;
     }
     $body = $this->templating->render('OpiferFormBundle:Email:notification.html.twig', ['post' => $post]);
     $message = \Swift_Message::newInstance()->setSender($this->sender)->setFrom($this->sender)->setTo($form->getNotificationEmail())->setSubject($form->getName())->setBody($body);
     $this->mailer->send($message);
 }
Exemplo n.º 2
0
 /**
  * @param \Swift_Mime_Message $message
  *
  * @return int
  */
 protected function send(\Swift_Mime_Message $message)
 {
     return $this->mailer->send($message);
 }