/** * Add header object to message object. * WARNING: Unfinished code. Don't expect it to work in older sm versions. * @param mixed $read array or string with message headers * @todo FIXME: rfc822header->parseHeader() does not return rfc822header object */ function addRFC822Header($read) { $header = new Rfc822Header(); $this->rfc822_header = $header->parseHeader($read); }
function sqimap_get_message($imap_stream, $id, $mailbox) { global $uid_support; $flags = array(); $read = sqimap_run_command($imap_stream, "FETCH {$id} (FLAGS BODYSTRUCTURE)", true, $response, $message, $uid_support); if ($read) { if (preg_match('/.+FLAGS\\s\\((.*)\\)\\s/AUi', $read[0], $regs)) { if (trim($regs[1])) { $flags = preg_split('/ /', $regs[1], -1, 'PREG_SPLIT_NI_EMPTY'); } } } else { echo "ERROR Yeah I know, not a very usefull errormessage (id = {$id}, mailbox = {$mailbox} sqimap_get_message)"; exit; } $bodystructure = implode('', $read); $msg = mime_structure($bodystructure, $flags); $read = sqimap_run_command($imap_stream, "FETCH {$id} BODY[HEADER]", true, $response, $message, $uid_support); $rfc822_header = new Rfc822Header(); $rfc822_header->parseHeader($read); $msg->rfc822_header = $rfc822_header; return $msg; }
$FirstTimeSee = !$message->is_seen; $message->is_seen = true; $messages[$uidvalidity][$passed_id] = $message; } else { // $message = sqimap_get_message($imapConnection, $passed_id, $mailbox); $message = $messages[$uidvalidity][$passed_id]; $FirstTimeSee = !$message->is_seen; } if (isset($passed_ent_id) && $passed_ent_id) { $message = $message->getEntity($passed_ent_id); if ($message->type0 != 'message' && $message->type1 != 'rfc822') { $message = $message->parent; } $read = sqimap_run_command($imapConnection, "FETCH {$passed_id} BODY[{$passed_ent_id}.HEADER]", true, $response, $msg, $uid_support); $rfc822_header = new Rfc822Header(); $rfc822_header->parseHeader($read); $message->rfc822_header = $rfc822_header; } else { $passed_ent_id = 0; } $header = $message->header; do_hook('html_top'); /****************************************/ /* Block for handling incoming url vars */ /****************************************/ if (isset($sendreceipt)) { if (!$message->is_mdnsent) { if (isset($identity)) { $final_recipient = getPref($data_dir, $username, 'email_address0', ''); } else { $final_recipient = getPref($data_dir, $username, 'email_address', '');
/** * Recursively parse embedded messages (if any) in the given * message, building correct rfc822 headers for each one * * @param object $msg The message object to scan for attached messages * NOTE: this is passed by reference! Changes made * within will affect the caller's copy of $msg! * @param int $id The top-level message UID on the IMAP server, even * if the $msg being passed in is only an attached entity * thereof. * @param resource $imap_stream A live connection to the IMAP server. * * @return void * * @since 1.5.2 * */ function parse_message_entities(&$msg, $id, $imap_stream) { if (!empty($msg->entities)) { foreach ($msg->entities as $i => $entity) { if (is_object($entity) && strtolower(get_class($entity)) == 'message') { if (!empty($entity->rfc822_header)) { $read = sqimap_run_command($imap_stream, "FETCH {$id} BODY[" . $entity->entity_id . ".HEADER]", true, $response, $message, TRUE); $rfc822_header = new Rfc822Header(); $rfc822_header->parseHeader($read); $msg->entities[$i]->rfc822_header = $rfc822_header; } parse_message_entities($msg->entities[$i], $id, $imap_stream); } } } }
/** * Returns a message array with all the information about a message. * See the documentation folder for more information about this array. * * @param resource $imap_stream imap connection * @param integer $id uid of the message * @param string $mailbox used for error handling, can be removed because we should return an error code and generate the message elsewhere * @return Message Message object */ function sqimap_get_message($imap_stream, $id, $mailbox) { // typecast to int to prohibit 1:* msgs sets $id = (int) $id; $flags = array(); $read = sqimap_run_command($imap_stream, "FETCH {$id} (FLAGS BODYSTRUCTURE)", true, $response, $message, TRUE); if ($read) { if (preg_match('/.+FLAGS\\s\\((.*)\\)\\s/AUi', $read[0], $regs)) { if (trim($regs[1])) { $flags = preg_split('/ /', $regs[1], -1, 'PREG_SPLIT_NI_EMPTY'); } } } else { /* the message was not found, maybe the mailbox was modified? */ global $sort, $startMessage, $color; $errmessage = _("The server couldn't find the message you requested.") . '<p>' . _("Most probably your message list was out of date and the message has been moved away or deleted (perhaps by another program accessing the same mailbox)."); /* this will include a link back to the message list */ error_message($errmessage, $mailbox, $sort, (int) $startMessage, $color); exit; } $bodystructure = implode('', $read); $msg = mime_structure($bodystructure, $flags); $read = sqimap_run_command($imap_stream, "FETCH {$id} BODY[HEADER]", true, $response, $message, TRUE); $rfc822_header = new Rfc822Header(); $rfc822_header->parseHeader($read); $msg->rfc822_header = $rfc822_header; return $msg; }