From faf8766fd2a34ad1eaf1545bab659ab459c074ad Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Thu, 31 Jul 2008 17:08:17 -0400
Subject: [PATCH] Save outgoing mail to selectable folder (#1324581)

---
 program/steps/mail/sendmail.inc |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)

diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 44f2bdf..090919e 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -284,12 +284,7 @@
     }
     else
     {
-      /*
-        We need to replace mime_content_type in a later release because the function
-        is deprecated in favour of File_Info
-      */
-      $ctype = rc_mime_content_type($attachment['path'], $attachment['mimetype']);
-      $ctype = str_replace('image/pjpeg', 'image/jpeg', $ctype); // #1484914
+      $ctype = str_replace('image/pjpeg', 'image/jpeg', $attachment['mimetype']); // #1484914
 
       // .eml attachments send inline
       $MAIL_MIME->addAttachment($attachment['path'],
@@ -348,37 +343,39 @@
     return;
     }
   
-  // set repliead flag
+  // set replied/forwarded flag
   if ($_SESSION['compose']['reply_uid'])
     $IMAP->set_flag($_SESSION['compose']['reply_uid'], 'ANSWERED');
+  else if ($_SESSION['compose']['forward_uid'])
+    $IMAP->set_flag($_SESSION['compose']['forward_uid'], 'FORWARDED');
 
-  } // End of SMTP Delivery Block
+} // End of SMTP Delivery Block
 
 
 
 // Determine which folder to save message
 if ($savedraft)
-  $store_target = 'drafts_mbox';
+  $store_target = $CONFIG['drafts_mbox'];
 else
-  $store_target = 'sent_mbox';
+  $store_target = isset($_POST['_store_target']) ? get_input_value('_store_target', RCUBE_INPUT_POST) : $CONFIG['sent_mbox'];
 
-if ($CONFIG[$store_target])
+if ($store_target)
   {
   // check if mailbox exists
-  if (!in_array_nocase($CONFIG[$store_target], $IMAP->list_mailboxes()))
-    $store_folder = $IMAP->create_mailbox($CONFIG[$store_target], TRUE);
+  if (!in_array_nocase($store_target, $IMAP->list_mailboxes()))
+    $store_folder = $IMAP->create_mailbox($store_target, TRUE);
   else
     $store_folder = TRUE;
   
   // append message to sent box
   if ($store_folder)
-    $saved = $IMAP->save_message($CONFIG[$store_target], $MAIL_MIME->getMessage());
+    $saved = $IMAP->save_message($store_target, $MAIL_MIME->getMessage());
 
   // raise error if saving failed
   if (!$saved)
     {
     raise_error(array('code' => 800, 'type' => 'imap', 'file' => __FILE__,
-                      'message' => "Could not save message in $CONFIG[$store_target]"), TRUE, FALSE);
+                      'message' => "Could not save message in $store_target"), TRUE, FALSE);
     
     $OUTPUT->show_message('errorsaving', 'error');
     $OUTPUT->send('iframe');

--
Gitblit v1.9.1