Example #1
0
File: Mail.php Project: horde/horde
 /**
  * Sends a SMART response.
  *
  * @throws Horde_ActiveSync_Exception
  */
 protected function _sendSmart()
 {
     $mime_message = $this->_raw->getMimeObject();
     // Need to remove content-type header from the incoming raw message
     // since in a smart request, we actually construct the full MIME msg
     // ourselves and the content-type in _headers only applies to the reply
     // text sent from the client, not the fully generated MIME message.
     $this->_headers->removeHeader('Content-Type');
     $this->_headers->removeHeader('Content-Transfer-Encoding');
     // Check for EAS 16.0 Forwardees
     if (!empty($this->_forwardees)) {
         $list = new Horde_Mail_Rfc822_List();
         foreach ($this->_forwardees as $forwardee) {
             $to = new Horde_Mail_Rfc822_Address($forwardee->email);
             $to->personal = $forwardee->name;
             $list->add($to);
         }
         $this->_headers->add('To', $list->writeAddress());
     }
     $mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
     $base_part = $this->imapMessage->getStructure();
     $plain_id = $base_part->findBody('plain');
     $html_id = $base_part->findBody('html');
     try {
         $body_data = $this->imapMessage->getMessageBodyData(array('protocolversion' => $this->_version, 'bodyprefs' => array(Horde_ActiveSync::BODYPREF_TYPE_MIME => true)));
     } catch (Horde_Exception_NotFound $e) {
         throw new Horde_ActiveSync_Exception($e->getMessage());
     }
     if (!empty($html_id)) {
         $mail->setHtmlBody($this->_getHtmlPart($html_id, $mime_message, $body_data, $base_part));
     } elseif (!empty($plain_id)) {
         $mail->setBody($this->_getPlainPart($plain_id, $mime_message, $body_data, $base_part));
     }
     if ($this->_forward) {
         foreach ($base_part->contentTypeMap() as $mid => $type) {
             if ($this->imapMessage->isAttachment($mid, $type)) {
                 $mail->addMimePart($this->imapMessage->getMimePart($mid));
             }
         }
     }
     foreach ($mime_message->contentTypeMap() as $mid => $type) {
         if ($mid != 0 && $mid != $mime_message->findBody('plain') && $mid != $mime_message->findBody('html')) {
             $mail->addMimePart($mime_message->getPart($mid));
         }
     }
     try {
         $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
         $this->_mailer = $mail;
     } catch (Horde_Mime_Exception $e) {
         throw new Horde_ActiveSync_Exception($e);
     }
 }
Example #2
0
 /**
  * Sends a SMART request.
  *
  * @throws Horde_ActiveSync_Exception
  */
 protected function _sendSmart()
 {
     $mime_message = $this->_raw->getMimeObject();
     $mail = new Horde_Mime_Mail($this->_headers->toArray(array('charset' => 'UTF-8')));
     $base_part = $this->imapMessage->getStructure();
     $plain_id = $base_part->findBody('plain');
     $html_id = $base_part->findBody('html');
     try {
         $body_data = $this->imapMessage->getMessageBodyData(array('protocolversion' => $this->_version, 'bodyprefs' => array(Horde_ActiveSync::BODYPREF_TYPE_MIME => true)));
     } catch (Horde_Exception_NotFound $e) {
         throw new Horde_ActiveSync_Exception($e->getMessage());
     }
     if (!empty($html_id)) {
         $mail->setHtmlBody($this->_getHtmlPart($html_id, $mime_message, $body_data, $base_part));
     }
     if (!empty($plain_id)) {
         $mail->setBody($this->_getPlainPart($plain_id, $mime_message, $body_data, $base_part));
     }
     if ($this->_forward) {
         foreach ($base_part->contentTypeMap() as $mid => $type) {
             if ($this->imapMessage->isAttachment($mid, $type)) {
                 $mail->addMimePart($this->imapMessage->getMimePart($mid));
             }
         }
     }
     foreach ($mime_message->contentTypeMap() as $mid => $type) {
         if ($mid != 0 && $mid != $mime_message->findBody('plain') && $mid != $mime_message->findBody('html')) {
             $mail->addMimePart($mime_message->getPart($mid));
         }
     }
     try {
         $mail->send($GLOBALS['injector']->getInstance('Horde_Mail'));
         $this->_mailer = $mail;
     } catch (Horde_Mime_Exception $e) {
         throw new Horde_ActiveSync_Exception($e);
     }
 }