+
+ // select folder where to save the sent message
+ $_SESSION['compose']['param']['sent_mbox'] = $RCMAIL->config->get('sent_mbox');
+
+ // pipe compose parameters thru plugins
+ $plugin = $RCMAIL->plugins->exec_hook('message_compose', $_SESSION['compose']);
+ $_SESSION['compose']['param'] = array_merge($_SESSION['compose']['param'], $plugin['param']);
+
+ // add attachments listed by message_compose hook
+ if (is_array($plugin['attachments'])) {
+ foreach ($plugin['attachments'] as $attach) {
+ // we have structured data
+ if (is_array($attach)) {
+ $attachment = $attach;
+ }
+ // only a file path is given
+ else {
+ $filename = basename($attach);
+ $attachment = array(
+ 'name' => $filename,
+ 'mimetype' => rc_mime_content_type($attach, $filename),
+ 'path' => $attach
+ );
+ }
+
+ // save attachment if valid
+ if (($attachment['data'] && $attachment['name']) || ($attachment['path'] && file_exists($attachment['path']))) {
+ $attachment = rcmail::get_instance()->plugins->exec_hook('attachment_save', $attachment);
+ }
+
+ if ($attachment['status'] && !$attachment['abort']) {
+ unset($attachment['data'], $attachment['status'], $attachment['abort']);
+ $_SESSION['compose']['attachments'][$attachment['id']] = $attachment;
+ }
+ }
+ }
+
+ // check if folder for saving sent messages exists and is subscribed (#1486802)
+ if ($sent_folder = $_SESSION['compose']['param']['sent_mbox']) {
+ rcmail_check_sent_folder($sent_folder, true);
+ }