Aleksander Machniak
2015-01-22 5d42a9353b3df5e08b7dfc2ac6a92978a89cceca
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;
}
@@ -273,9 +277,10 @@
    }
    // append doctype and html/body wrappers
    $message_body = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">'
        . "\r\n<html><body" . (!empty($bstyle) ? " style='" . implode($bstyle, '; ') . "'" : '') . ">\r\n"
        . $message_body;
    $bstyle       = !empty($bstyle) ? (" style='" . implode($bstyle, '; ') . "'") : '';
    $message_body = '<html><head>'
        . '<meta http-equiv="Content-Type" content="text/html; charset=' . $message_charset . '" /></head>'
        . "<body" . $bstyle . ">\r\n" . $message_body;
}
if (!$savedraft) {
@@ -310,10 +315,16 @@
        $COMPOSE['spell_checked'] = true;
        if (!$spell_result) {
            $result = $isHtml ? $spellchecker->get_words() : $spellchecker->get_xml();
            if ($isHtml) {
                $result['words']      = $spellchecker->get();
                $result['dictionary'] = (bool) $RCMAIL->config->get('spellcheck_dictionary');
            }
            else {
                $result = $spellchecker->get_xml();
            }
            $OUTPUT->show_message('mispellingsfound', 'error');
            $OUTPUT->command('spellcheck_resume', $isHtml, $result);
            $OUTPUT->command('spellcheck_resume', $result);
            $OUTPUT->send('iframe');
        }
    }
@@ -421,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);
        }
@@ -442,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);
@@ -462,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
@@ -477,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";
}
@@ -517,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);
@@ -561,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');
    }
}
@@ -679,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'];
    }
@@ -738,11 +745,11 @@
/**
 * go from this:
 * <img src="http[s]://.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
 * <img src="http[s]://.../tinymce/plugins/emoticons/img/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
 *
 * to this:
 *
 * <img src="/path/on/server/.../tiny_mce/plugins/emotions/images/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
 * <img src="/path/on/server/.../tinymce/plugins/emoticons/img/smiley-cool.gif" border="0" alt="Cool" title="Cool" />
 */
function rcmail_fix_emoticon_paths($mime_message)
{
@@ -753,7 +760,7 @@
    // remove any null-byte characters before parsing
    $body = preg_replace('/\x00/', '', $body);
    $searchstr = 'program/js/tiny_mce/plugins/emotions/img/';
    $searchstr = 'program/js/tinymce/plugins/emoticons/img/';
    $offset = 0;
    // keep track of added images, so they're only added once