/**
  * @param form_persistentdocument_baseform $form
  * @param form_persistentdocument_response $response
  * @param block_BlockRequest $request
  * @param array $result
  * @param String $acknowledgmentReceiver
  * @param String $replyTo
  * @return void
  */
 protected function sendAcknowledgement($form, $response, $request, $result, $acknowledgmentReceiver, $replyTo)
 {
     $recipients = new mail_MessageRecipients();
     $recipients->setTo(array($acknowledgmentReceiver));
     $parameters = $this->getAcknowledgementNotificationParameters($form, $response, $request, $result, $acknowledgmentReceiver, $replyTo);
     if (Framework::isDebugEnabled()) {
         Framework::debug(__METHOD__ . " Form \"" . $form->getLabel() . "\" (id=" . $form->getId() . ")");
         Framework::debug(__METHOD__ . " Parameters: " . var_export($parameters, true));
         Framework::debug(__METHOD__ . " To      : " . join(", ", $recipients->getTo()));
         Framework::debug(__METHOD__ . " ReplyTo : " . $replyTo);
     }
     $ns = notification_NotificationService::getInstance();
     $ns->setMessageService(MailService::getInstance());
     $notification = $form->getAcknowledgmentNotification();
     $senderEmail = $this->getOverrideNotificationSender($form);
     return $ns->send($notification, $recipients, $parameters, 'form', $replyTo, $senderEmail);
 }
 /**
  * @param form_persistentdocument_form $form
  * @param form_persistentdocument_response $response
  * @param block_BlockRequest $request
  * @param String $copyMail
  * @param String $replyTo
  * @return void
  */
 private function sendEmail($form, $response, $request, $copyMail, $replyTo)
 {
     $recipients = new mail_MessageRecipients();
     if ($request->hasParameter('receiverIds')) {
         $this->handleReceveirIds($request->getParameter('receiverIds'), $recipients);
     }
     // Determine the message recipients for this form.
     // Note that the following method may be overriden to allow the developper
     // to build specific mail recipients, depending on the request data for
     // example.
     $this->buildMessageRecipients($form, $recipients, $request);
     if (!$recipients->isEmpty()) {
         if ($form->getMessageSendingType() == self::SEND_EMAIL_AND_APPEND_TO_MAILBOX) {
             $messageService = mailbox_MessageService::getInstance();
             Framework::debug(__METHOD__ . " Getting mailbox_MessageService instance.");
         } else {
             $messageService = MailService::getInstance();
             Framework::debug(__METHOD__ . " Getting MailService instance.");
         }
         $contentTemplate = TemplateLoader::getInstance()->setPackageName('modules_form')->setMimeContentType(K::HTML)->load('Form-MailContent');
         $contentTemplate->setAttribute('items', $response->getAllData());
         $contentTemplate->setAttribute('response', $response->getResponseInfos());
         $parameters = $response->getData();
         $parameters[self::CONTENT_REPLACEMENT_NAME] = $contentTemplate->execute();
         $parameters[self::FORM_LABEL_REPLACEMENT_NAME] = $form->getLabel();
         if (Framework::isDebugEnabled()) {
             Framework::debug(__METHOD__ . " Form \"" . $form->getLabel() . "\" (id=" . $form->getId() . ")");
             Framework::debug(__METHOD__ . " Parameters: " . var_export($parameters, true));
             if ($recipients->hasTo()) {
                 Framework::debug(__METHOD__ . " To      : " . join(", ", $recipients->getTo()));
             }
             if ($recipients->hasBCC()) {
                 Framework::debug(__METHOD__ . " CC      : " . join(", ", $recipients->getCC()));
             }
             if ($recipients->hasBCC()) {
                 Framework::debug(__METHOD__ . " BCC     : " . join(", ", $recipients->getBcc()));
             }
             Framework::debug(__METHOD__ . " ReplyTo : " . $replyTo);
         }
         $ns = notification_NotificationService::getInstance();
         $ns->setMessageService($messageService);
         if ($copyMail === null) {
             return $ns->send($form->getNotification(), $recipients, $parameters, 'form', $replyTo, $this->getOverrideNotificationSender($form));
         } else {
             $copyRecipient = new mail_MessageRecipients();
             $copyRecipient->setTo(array($copyMail));
             $notification = $form->getNotification();
             $sender = $this->getOverrideNotificationSender($form);
             return $ns->send($notification, $recipients, $parameters, 'form', $replyTo, $sender) && $ns->send($notification, $copyRecipient, $parameters, 'form', $replyTo, $sender);
         }
     }
     return true;
 }