Make message ID available after message is sent. Not the best solution, but it's...
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 6 Feb 2008 08:13:33 +0000 (08:13 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Wed, 6 Feb 2008 08:13:33 +0000 (08:13 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12919 7612ce4b-ef26-0410-bec9-ea0150e637f0

class/deliver/Deliver.class.php
src/compose.php

index bb02bdde09bdb5599eae75564a3e5af896499f78..cbf12187c752d51d330cb57a63666bad004d3475 100644 (file)
  */
 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])";
index 39ea5103db3cb935b8012f6357e17d66402dfc9c..6599099b446d084d317e855501f0923ca834ddf2 100644 (file)
@@ -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  = '<br />'.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) {