* appended message.
* DEFAULT: internaldate will be the same date as when
* the message was appended.
- * 'messageid' - (string) For servers/drivers that support the UIDPLUS
- * IMAP extension, the UID of the appended message(s) can be
- * determined automatically. If this extension is not
- * available, the message-id of each message is needed to
- * determine the UID. If UIDPLUS is not available, and this
- * option is not defined, append() will return true only.
- * DEFAULT: If UIDPLUS is supported, or this string is
- * provided, appended ID is returned. Else, append() will
- * return true.
* </pre>
* @param array $options Additonal options:
* <pre>
* DEFAULT: No.
* </pre>
*
- * @return mixed An array of the UIDs of the appended messages (if server
- * supports UIDPLUS extension or 'messageid' is defined)
- * or true.
+ * @return array The UIDs of the appended messages.
* @throws Horde_Imap_Client_Exception
*/
public function append($mailbox, $data, $options = array())
return $ret;
}
- $msgid = false;
$uids = array();
while (list(,$val) = each($data)) {
- if (empty($val['messageid'])) {
- $uids[] = null;
- } else {
- $msgid = true;
+ if (is_string($data['data'])) {
+ $text = $data;
+ } elseif (is_resource($data['data'])) {
+ $text = '';
+ rewind($data['data']);
+ while ($in = fread($data['data'], 1024)) {
+ $text .= $in;
+ if (preg_match("/\n\r*\n\r*/", $text)) {
+ break;
+ }
+ }
+ }
+
+ $headers = Horde_Mime_Headers::parseHeaders($text);
+ $msgid = $headers->getValue('message-id');
+
+ if ($msgid) {
$search_query = new Horde_Imap_Client_Search_Query();
- $search_query->headerText('Message-ID', $val['messageid']);
+ $search_query->headerText('Message-ID', $msgid);
$uidsearch = $this->search($mailbox, $search_query);
$uids[] = reset($uidsearch['match']);
}
}
- return $msgid ? $uids : true;
+ return $uids;
}
/**
* set the $MDNSent keyword. However, IMP doesn't write MDN headers
* until send time so no need to set the flag here. */
- /* Get the message ID. */
- $headers = Horde_Mime_Headers::parseHeaders($data);
-
$drafts_mbox = IMP::folderPref($GLOBALS['prefs']->getValue('drafts_folder'), true);
$old_uid = $this->getMetadata('draft_uid');
/* Add the message to the mailbox. */
try {
- $ids = $GLOBALS['imp_imap']->ob()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags, 'messageid' => $headers->getValue('message-id'))));
+ $ids = $GLOBALS['imp_imap']->ob()->append($drafts_mbox, array(array('data' => $data, 'flags' => $append_flags)));
if ($old_uid) {
$GLOBALS['injector']->getInstance('IMP_Message')->delete(array($old_uid), array('nuke' => true));
try {
$res = $GLOBALS['imp_imap']->ob()->fetch($mbox, array(
Horde_Imap_Client::FETCH_HEADERTEXT => array(array('peek' => true)),
- Horde_Imap_Client::FETCH_ENVELOPE => true,
Horde_Imap_Client::FETCH_FLAGS => true
), array('ids' => array($index)));
$res = reset($res);
unset($res['flags'][$pos]);
}
- $uid = $GLOBALS['imp_imap']->ob()->append($mbox, array(array('data' => $message->toString(array('headers' => $res['headertext'][0], 'stream' => true)), 'flags' => $res['flags'], 'messageid' => $res['envelope']['message-id'])));
+ $uid = $GLOBALS['imp_imap']->ob()->append($mbox, array(array('data' => $message->toString(array('headers' => $res['headertext'][0], 'stream' => true)), 'flags' => $res['flags'])));
} catch (Horde_Imap_Client_Exception $e) {
throw new Horde_Exception(_("An error occured while attempting to strip the attachment."));
}