/**
  * Action to show and process the contact form
  * @return null
  */
 public function indexAction()
 {
     $recipient = $this->properties->getWidgetProperty(self::PROPERTY_RECIPIENT);
     if (!$recipient) {
         $this->addWarning(self::TRANSLATION_WARNING_RECIPIENT);
         return;
     }
     $captchaManager = CaptchaManager::getInstance();
     $form = new ContactWidgetForm($this->request->getBasePath());
     $captchaManager->addCaptchaToForm($form);
     if ($form->isSubmitted()) {
         try {
             $form->validate();
             $captchaManager->validateCaptcha($form);
             $name = $form->getName();
             $email = $form->getEmail();
             $message = $form->getMessage();
             $subject = $this->properties->getWidgetProperty(self::PROPERTY_SUBJECT);
             $mail = new Message();
             $mail->setFrom($name . ' <' . $email . '>');
             $mail->setTo($recipient);
             $mail->setSubject($subject);
             $mail->setMessage($message);
             $mail->send();
             $this->addInformation(self::TRANSLATION_MESSAGE_SENT);
             $this->response->setRedirect($this->request->getBasePath());
             return;
         } catch (ValidationException $e) {
         } catch (CaptchaException $e) {
         }
     }
     $captchaView = $captchaManager->getCaptchaView($form);
     $view = new ContactWidgetView($form, $captchaView);
     $this->response->setView($view);
 }
 /**
  * @expectedException zibo\ZiboException
  */
 public function testSetDefaultCaptchaThrowsExceptionWhenNameDoesNotExist()
 {
     $manager = CaptchaManager::getInstance();
     $manager->setDefaultCaptchaName('unexistant');
 }