From 5d42a9353b3df5e08b7dfc2ac6a92978a89cceca Mon Sep 17 00:00:00 2001 From: Aleksander Machniak <alec@alec.pl> Date: Thu, 22 Jan 2015 04:19:51 -0500 Subject: [PATCH] Fix bug where drafts list wasn't refreshed after draft message was sent from another window (#1490238) --- program/steps/mail/sendmail.inc | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-) diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc index 4737ce3..76a8188 100644 --- a/program/steps/mail/sendmail.inc +++ b/program/steps/mail/sendmail.inc @@ -77,7 +77,7 @@ $mailcc = rcmail_email_input_format(rcube_utils::get_input_value('_cc', rcube_utils::INPUT_POST, TRUE, $message_charset), true); $mailbcc = rcmail_email_input_format(rcube_utils::get_input_value('_bcc', rcube_utils::INPUT_POST, TRUE, $message_charset), true); -if ($EMAIL_FORMAT_ERROR) { +if ($EMAIL_FORMAT_ERROR && !$savedraft) { $OUTPUT->show_message('emailformaterror', 'error', array('email' => $EMAIL_FORMAT_ERROR)); $OUTPUT->send('iframe'); } @@ -144,7 +144,7 @@ $http_header .= $nldlm . ' via '; } - $host = $_SERVER['REMOTE_ADDR']; + $host = $_SERVER['REMOTE_ADDR']; $hostname = gethostbyaddr($host); if ($encrypt) { @@ -171,7 +171,7 @@ $headers['Date'] = $RCMAIL->user_date(); $headers['From'] = rcube_charset::convert($from_string, RCUBE_CHARSET, $message_charset); -$headers['To'] = $mailto; +$headers['To'] = $mailto; // additional recipients if (!empty($mailcc)) { @@ -187,6 +187,10 @@ $OUTPUT->send('iframe'); } } + +$dont_override = (array) $RCMAIL->config->get('dont_override'); +$mdn_enabled = in_array('mdn_default', $dont_override) ? $RCMAIL->config->get('mdn_default') : !empty($_POST['_mdn']); +$dsn_enabled = in_array('dsn_default', $dont_override) ? $RCMAIL->config->get('dsn_default') : !empty($_POST['_dsn']); // add subject $headers['Subject'] = trim(rcube_utils::get_input_value('_subject', rcube_utils::INPUT_POST, TRUE, $message_charset)); @@ -228,7 +232,7 @@ } } -if (!empty($_POST['_receipt'])) { +if ($mdn_enabled) { $headers['Return-Receipt-To'] = $from_string; $headers['Disposition-Notification-To'] = $from_string; } @@ -428,8 +432,7 @@ $attachment = $RCMAIL->plugins->exec_hook('attachment_get', $attachment); if ($isHtml) { - $dispurl = '/\ssrc\s*=\s*[\'"]*\S+display-attachment\S+file=rcmfile' - . preg_quote($attachment['id']) . '[\s\'"]*/'; + $dispurl = '/[\'"]\S+display-attachment\S+file=rcmfile' . preg_quote($attachment['id']) . '[\'"]/'; $message_body = $MAIL_MIME->getHTMLBody(); $is_inline = preg_match($dispurl, $message_body); } @@ -449,7 +452,7 @@ $cid .= '@localhost'; } - $message_body = preg_replace($dispurl, ' src="cid:' . $cid . '" ', $message_body); + $message_body = preg_replace($dispurl, '"cid:' . $cid . '"', $message_body); $MAIL_MIME->setHTMLBody($message_body); @@ -469,7 +472,8 @@ $attachment['data'] ? false : true, $ctype == 'message/rfc822' ? '8bit' : 'base64', 'attachment', - '', '', '', + $attachment['charset'], + '', '', $folding ? 'quoted-printable' : NULL, $folding == 2 ? 'quoted-printable' : NULL, '', RCUBE_CHARSET @@ -484,15 +488,11 @@ $transfer_encoding = $RCMAIL->config->get('force_7bit') ? 'quoted-printable' : '8bit'; } else { - $text_charset = ''; + $text_charset = 'US-ASCII'; $transfer_encoding = '7bit'; } if ($flowed) { - if (!$text_charset) { - $text_charset = 'US-ASCII'; - } - $text_charset .= ";\r\n format=flowed"; } @@ -524,9 +524,7 @@ } // Handle Delivery Status Notification request - if (!empty($_POST['_dsn'])) { - $smtp_opts['dsn'] = true; - } + $smtp_opts['dsn'] = $dsn_enabled; $sent = $RCMAIL->deliver_message($MAIL_MIME, $from, $mailto, $smtp_error, $mailbody_file, $smtp_opts); @@ -568,9 +566,11 @@ $store_target = $drafts_mbox; } else if (!$RCMAIL->config->get('no_save_sent_messages')) { - $store_target = rcube_utils::get_input_value('_store_target', rcube_utils::INPUT_POST); - if (!strlen($store_target)) { - $sore_target = $RCMAIL->config->get('sent_mbox'); + if (isset($_POST['_store_target'])) { + $store_target = rcube_utils::get_input_value('_store_target', rcube_utils::INPUT_POST); + } + else { + $store_target = $RCMAIL->config->get('sent_mbox'); } } @@ -686,7 +686,7 @@ else { $folders = array(); - if ($COMPOSE['mode'] == 'reply' || $COMPOSE['mode'] == 'forward') { + if (in_array($COMPOSE['mode'], array('reply', 'forward', 'draft'))) { $folders[] = $COMPOSE['mailbox']; } -- Gitblit v1.9.1