From: pdontthink Date: Wed, 6 Feb 2008 08:13:33 +0000 (+0000) Subject: Make message ID available after message is sent. Not the best solution, but it's... X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=commitdiff_plain;h=b67d61ee36dc1cc591fcb6c84e344ec9e10f7ea4;hp=aa04b27dce638ee05b60e9c8e7b2539e6426848a Make message ID available after message is sent. Not the best solution, but it's smallish and SM design doesn't suit very well git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12919 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- diff --git a/class/deliver/Deliver.class.php b/class/deliver/Deliver.class.php index bb02bdde..cbf12187 100644 --- a/class/deliver/Deliver.class.php +++ b/class/deliver/Deliver.class.php @@ -28,6 +28,13 @@ */ class Deliver { + /** + * Most recently calculated Message-ID + * External code should NEVER access this directly! + * @var string + */ + var $message_id; + /** * function mail - send the message parts to the SMTP stream * @@ -52,8 +59,12 @@ class Deliver { * an overloaded version of this method * if needed. * - * @return integer $raw_length The number of bytes written (or that would - * have been written) to the output stream + * @return array An array containing at least these elements in this order: + * - The number of bytes written (or that would have been + * written) to the output stream + * - The message ID (WARNING: if $stream is FALSE, this + * may not be supplied, or may not be accurate) + * */ function mail($message, $stream=false, $reply_id=0, $reply_ent_id=0, $extra=NULL) { @@ -104,7 +115,7 @@ class Deliver { $this->send_mail($message, $header, $boundary, $stream, $raw_length, $extra); - return $raw_length; + return array($raw_length, $this->message_id); } /** @@ -505,6 +516,8 @@ class Deliver { $message_id.= $REMOTE_ADDR; } $message_id .= '.' . time() . '.squirrel@' . $SERVER_NAME .'>'; + $this->message_id = $message_id; + /* Make an RFC822 Received: line */ if (isset($REMOTE_HOST)) { $received_from = "$REMOTE_HOST ([$REMOTE_ADDR])"; diff --git a/src/compose.php b/src/compose.php index 39ea5103..6599099b 100644 --- a/src/compose.php +++ b/src/compose.php @@ -1469,10 +1469,14 @@ function getByteSize($ini_size) { * In the future the responsible backend should be automaticly loaded * and conf.pl should show a list of available backends. * The message also should be constructed by the message class. + * + * @return boolean FALSE if delivery failed, or some non-FALSE value + * upon success. + * */ function deliverMessage($composeMessage, $draft=false) { global $send_to, $send_to_cc, $send_to_bcc, $mailprio, $subject, $body, - $username, $identity, $idents, $data_dir, + $username, $identity, $idents, $data_dir, $message_id, $request_mdn, $request_dr, $default_charset, $useSendmail, $domain, $action, $default_move_to_sent, $move_to_sent, $imapServerAddress, $imapPort, $sent_folder, $key; @@ -1596,11 +1600,11 @@ function deliverMessage($composeMessage, $draft=false) { if (sqimap_mailbox_exists ($imap_stream, $draft_folder)) { require_once(SM_PATH . 'class/deliver/Deliver_IMAP.class.php'); $imap_deliver = new Deliver_IMAP(); - $length = $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $draft_folder); + list($success, $ignore) = $imap_deliver->mail($composeMessage, $imap_stream, $reply_id, $reply_ent_id, $draft_folder); sqimap_logout($imap_stream); unset ($imap_deliver); $composeMessage->purgeAttachments(); - return $length; + return $success; } else { $msg = '
'.sprintf(_("Error: Draft folder %s does not exist."), htmlspecialchars($draft_folder)); plain_error_message($msg); @@ -1609,7 +1613,7 @@ function deliverMessage($composeMessage, $draft=false) { } $success = false; if ($stream) { - $length = $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id); + list($ignore, $message_id) = $deliver->mail($composeMessage, $stream, $reply_id, $reply_ent_id); $success = $deliver->finalizeStream($stream); } if (!$success) {