Example #1
0
 /**
  * Implementation of FeedsImportBatch::getRaw();
  */
 public function getRaw()
 {
     $mailbox = mailhandler_mailbox_load($this->mailbox);
     if ($class = mailhandler_plugin_load_class('mailhandler', $mailbox->settings['retrieve'], 'retrieve', 'handler')) {
         if ($messages = $class->retrieve($mailbox, $this->filter)) {
             return array('messages' => $messages, 'mailbox' => $mailbox);
         }
     }
 }
 public function authenticate(&$message, $mailbox)
 {
     if ($plugin = $this->config['authenticate_plugin']) {
         if ($class = mailhandler_plugin_load_class('mailhandler', $plugin, 'authenticate', 'handler')) {
             $message['authenticated_uid'] = $class->authenticate($message, $mailbox);
         }
     }
 }
 /**
  * Retrieve individual messages from an IMAP result.
  *
  * @param $result
  *   IMAP stream.
  * @param object $mailbox
  *   Mailbox to retrieve from.
  * @param int $msg_number
  *   IMAP message number.
  * @param string $filter_name
  *   Mailhandler Filter plugin to use.
  * @return array
  *   Retrieved message, or FALSE if message cannot / should not be retrieved.
  */
 function retrieve_message($result, $mailbox, $msg_number, $filter_name)
 {
     extract($mailbox->settings);
     $header = imap_headerinfo($result, $msg_number);
     // Check to see if we should retrieve this message at all
     if ($filter = mailhandler_plugin_load_class('mailhandler', $filter_name, 'filters', 'handler')) {
         if (!$filter->fetch($header)) {
             return FALSE;
         }
     }
     // Initialize the subject in case it's missing.
     if (!isset($header->subject)) {
         $header->subject = '';
     }
     $body_text = $this->get_part($result, $msg_number, 'text/plain', FALSE, FALSE, $encoding);
     $body_html = $this->get_part($result, $msg_number, 'text/html', FALSE, FALSE, $encoding);
     if (!$body_text && $body_html) {
         $body_text = $body_html;
     } elseif ($body_text && !$body_html) {
         $body_html = $body_text;
     }
     // Parse MIME parts, so all mailhandler modules have access to
     // the full array of mime parts without having to process the email.
     $mimeparts = $this->get_parts($result, $msg_number);
     // Is this an empty message with no body and no mimeparts?
     if (!$body_text && !$body_html && !$mimeparts) {
         $message = FALSE;
     } else {
         $imap_uid = $type == 'pop3' ? $this->fetch_uid($mailbox, $msg_number) : imap_uid($result, $msg_number);
         $message = compact('header', 'body_text', 'body_html', 'mimeparts', 'imap_uid');
     }
     return $message;
 }
 /**
  * Retrieve individual messages from an IMAP result.
  *
  * @param $result
  *   IMAP stream.
  * @param object $mailbox
  *   Mailbox to retrieve from.
  * @param int $msg_number
  *   IMAP message number.
  * @param string $filter_name
  *   Mailhandler Filter plugin to use.
  *
  * @return array|false
  *   Retrieved message, or FALSE if message cannot / should not be retrieved.
  */
 function retrieve_message($result, $mailbox, $msg_number, $filter_name)
 {
     extract($mailbox->settings);
     $header = imap_headerinfo($result, $msg_number);
     // Check to see if we should retrieve this message at all
     if ($filter = mailhandler_plugin_load_class('mailhandler', $filter_name, 'filters', 'handler')) {
         if (!$filter->fetch($header)) {
             return FALSE;
         }
     }
     // Initialize the subject in case it's missing.
     if (!isset($header->subject)) {
         $header->subject = '';
     }
     // Parse MIME parts.
     $parts = $this->get_parts($result, $msg_number);
     $message = FALSE;
     // Is this an empty message with no body and no mimeparts?
     if (!empty($parts)) {
         $imap_uid = $type == 'pop3' ? $this->fetch_uid($mailbox, $msg_number) : imap_uid($result, $msg_number);
         $message = compact('header', 'imap_uid');
         $message['body_text'] = $parts['text_body'] ? $parts['text_body'] : $parts['html_body'];
         $message['body_html'] = $parts['html_body'] ? $parts['html_body'] : $parts['text_body'];
         $message['mimeparts'] = $parts['attachments'];
     }
     return $message;
 }