summaryrefslogtreecommitdiff
path: root/program/steps/mail
diff options
context:
space:
mode:
Diffstat (limited to 'program/steps/mail')
-rw-r--r--program/steps/mail/get.inc16
-rw-r--r--program/steps/mail/sendmail.inc22
2 files changed, 22 insertions, 16 deletions
diff --git a/program/steps/mail/get.inc b/program/steps/mail/get.inc
index 995a4857f..521f47735 100644
--- a/program/steps/mail/get.inc
+++ b/program/steps/mail/get.inc
@@ -63,19 +63,21 @@ else if ($pid = get_input_value('_part', RCUBE_INPUT_GET))
$mimetype = sprintf('%s/%s', $ctype_primary, $ctype_secondary);
$filename = $part->d_parameters['filename'] ? $part->d_parameters['filename'] : $part->ctype_parameters['name'];
- // send correct headers for content type and length
+ header("Expires: 0");
+ header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
+ header("Cache-Control: private", false);
+ header("Content-Transfer-Encoding: binary");
+ header(sprintf('Content-Disposition: attachment; filename="%s";',
+ $filename ? rcube_imap::decode_mime_string($filename) : "roundcube.$ctype_secondary"));
+
+ // send download headers
if ($_GET['_download'])
{
- // send download headers
+ header("Cache-Control: private", false);
header("Content-Type: application/octet-stream");
- header(sprintf('Content-Disposition: attachment; filename="%s"',
- $filename ? rcube_imap::decode_mime_string($filename) : "roundcube.$ctype_secondary"));
}
else
- {
header("Content-Type: $mimetype");
- header(sprintf('Content-Disposition: inline; filename="%s"', rcube_imap::decode_mime_string($filename)));
- }
// We need to set the following headers to make downloads work using IE in HTTPS mode.
if (isset($_SERVER['HTTPS']))
diff --git a/program/steps/mail/sendmail.inc b/program/steps/mail/sendmail.inc
index 7c7727bba..ea8264fec 100644
--- a/program/steps/mail/sendmail.inc
+++ b/program/steps/mail/sendmail.inc
@@ -151,8 +151,8 @@ if (empty($_POST['_to']) && empty($_POST['_subject']) && $_POST['_message'])
$input_charset = $OUTPUT->get_charset();
$message_charset = isset($_POST['_charset']) ? $_POST['_charset'] : $input_charset;
-$mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m');
-$mailto_replace = array(', ', ', ', '');
+$mailto_regexp = array('/[,;]\s*[\r\n]+/', '/[\r\n]+/', '/[,;]\s*$/m', '/;/');
+$mailto_replace = array(', ', ', ', '', ',');
// replace new lines and strip ending ', '
$mailto = preg_replace($mailto_regexp, $mailto_replace, get_input_value('_to', RCUBE_INPUT_POST, TRUE, $message_charset));
@@ -170,7 +170,7 @@ if (empty($identity_arr['string']))
// compose headers array
$headers = array('Date' => date('D, j M Y H:i:s O'),
'From' => rcube_charset_convert($identity_arr['string'], $CHARSET, $message_charset),
- 'To' => rcube_charset_convert($mailto, $input_charset, $message_charset));
+ 'To' => $mailto);
// additional recipients
if (!empty($_POST['_cc']))
@@ -301,10 +301,11 @@ $msg_body = $MAIL_MIME->get($message_param);
// unset to save memory.
unset($MAIL_MIME->_parts);
+// encoding subject header with mb_encode provides better results with asian characters
if ($MBSTRING && function_exists("mb_encode_mimeheader"))
{
mb_internal_encoding($message_charset);
- $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q');
+ $mb_subject = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q');
mb_internal_encoding($CHARSET);
}
@@ -326,12 +327,12 @@ if (!$savedraft) {
$send_headers = $headers;
unset($send_headers['Bcc']);
- // generate message headers
- $header_str = $MAIL_MIME->txtHeaders($send_headers);
+ if (!empty($mb_subject))
+ $send_headers['Subject'] = $mb_subject;
// send message
$smtp_response = array();
- $sent = smtp_mail($from, $a_recipients, $header_str, $msg_body, $smtp_response);
+ $sent = smtp_mail($from, $a_recipients, $MAIL_MIME->txtHeaders($send_headers), $msg_body, $smtp_response);
// log error
if (!$sent)
@@ -352,14 +353,17 @@ if (!$savedraft) {
$headers_php = $MAIL_MIME->_headers;
unset($headers_php['To'], $headers_php['Subject']);
+ if (!empty($mb_subject))
+ $headers_enc['Subject'] = $mb_subject;
+
// reset stored headers and overwrite
$MAIL_MIME->_headers = array();
$header_str = $MAIL_MIME->txtHeaders($headers_php);
if (ini_get('safe_mode'))
- $sent = mail($headers_enc['To'], $headers['Subject'], $msg_body, $header_str);
+ $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str);
else
- $sent = mail($headers_enc['To'], $headers['Subject'], $msg_body, $header_str, "-f$from");
+ $sent = mail($headers_enc['To'], $headers_enc['Subject'], $msg_body, $header_str, "-f$from");
}