Thomas Bruederli
2015-04-17 a3644638aaf0418598196a870204e0b632a4c8ad
program/steps/mail/sendmail.inc
@@ -113,6 +113,12 @@
        $from = null;
}
// check 'From' address (identity may be incomplete)
if (!$savedraft && !$saveonly && empty($from)) {
    $OUTPUT->show_message('nofromaddress', 'error');
    $OUTPUT->send('iframe');
}
if (!$from_string && $from) {
    $from_string = $from;
}
@@ -505,25 +511,15 @@
$MAIL_MIME->setParam('html_charset', $message_charset);
$MAIL_MIME->setParam('text_charset', $text_charset);
// encoding subject header with mb_encode provides better results with asian characters
if (function_exists('mb_encode_mimeheader')) {
    mb_internal_encoding($message_charset);
    $headers['Subject'] = mb_encode_mimeheader($headers['Subject'],
        $message_charset, 'Q', "\r\n", 8);
    mb_internal_encoding(RCUBE_CHARSET);
}
// pass headers to message object
$MAIL_MIME->headers($headers);
// Begin SMTP Delivery Block
if (!$savedraft) {
    // check 'From' address (identity may be incomplete)
    if (empty($from)) {
        $OUTPUT->show_message('nofromaddress', 'error');
        $OUTPUT->send('iframe');
    }
// This hook allows to modify the message before send or save action
$plugin    = $RCMAIL->plugins->exec_hook('message_ready', array('message' => $MAIL_MIME));
$MAIL_MIME = $plugin['message'];
// Begin SMTP Delivery Block
if (!$savedraft && !$saveonly) {
    // Handle Delivery Status Notification request
    $smtp_opts['dsn'] = $dsn_enabled;
@@ -601,8 +597,9 @@
            else {
                $temp_dir      = $RCMAIL->config->get('temp_dir');
                $mailbody_file = tempnam($temp_dir, 'rcmMsg');
                $msg           = $MAIL_MIME->saveMessageBody($mailbody_file);
                if (!PEAR::isError($msg = $MAIL_MIME->saveMessageBody($mailbody_file))) {
                if (!is_a($msg, 'PEAR_Error')) {
                    $msg = $mailbody_file;
                }
            }
@@ -612,7 +609,7 @@
            $headers = '';
        }
        if (PEAR::isError($msg)) {
        if (is_a($msg, 'PEAR_Error')) {
            rcube::raise_error(array('code' => 650, 'type' => 'php',
                'file' => __FILE__, 'line' => __LINE__,
                'message' => "Could not create message: ".$msg->getMessage()),
@@ -800,7 +797,7 @@
                if (!in_array($image_name, $included_images)) {
                    // add the image to the MIME message
                    $res = $mime_message->addHTMLImage($img_file, 'image/gif', '', true, $image_name);
                    if (PEAR::isError($res)) {
                    if (is_a($res, 'PEAR_Error')) {
                        $RCMAIL->output->show_message("emoticonerror", 'error');
                        continue;
                    }