thomascube
2008-06-20 2da368e6633ae4dec5d9b02ec3f4b693ffc9fb76
program/steps/mail/func.inc
@@ -534,12 +534,23 @@
  }
  // text/html
  else if ($part->ctype_secondary == 'html') {
    // charset was converted to UTF-8 in rcube_imap::get_message_part() -> change charset specification in HTML accordingly
    $html = $part->body;
    if(preg_match('/(\s+content=[\'"]\w+\/\w+;\s+charset)=([a-z0-9-]+)/i', $html))
      $html = preg_replace('/(\s+content=[\'"]\w+\/\w+;\s+charset)=([a-z0-9-]+)/i', '\\1='.RCMAIL_CHARSET, $html);
    else {
      // add <head> for malformed messages, washtml cannot work without that
      if (!preg_match('/<head>(.*)<\/head>/m', $html))
        $html = '<head></head>' . $html;
      $html = substr_replace($html, '<meta http-equiv="Content-Type" content="text/html; charset='.RCMAIL_CHARSET.'" />', intval(stripos($html, '</head>')), 0);
    }
    // clean HTML with washhtml by Frederic Motte
    $body = washtml::wash($part->body, array(
    $body = washtml::wash($html, array(
      'show_washed' => false,
      'allow_remote' => $safe,
      'blocked_src' => "./program/blocked.gif",
      'charset' => 'UTF-8',
      'charset' => RCMAIL_CHARSET,
      'cid_map' => $part->replaces,
      ), $full_inline);
@@ -549,6 +560,7 @@
  }
  // text/enriched
  else if ($part->ctype_secondary=='enriched') {
    $part->ctype_secondary = 'html';
    return Q(enriched_to_html($body), 'show');
  }
  else
@@ -645,6 +657,10 @@
  // get associative array of headers object
  if (!$headers)
    $headers = is_object($MESSAGE->headers) ? get_object_vars($MESSAGE->headers) : $MESSAGE->headers;
  // add empty subject if none exsists
  if (empty($headers['subject']))
    $headers['subject'] = rcube_label('nosubject');
  
  $header_count = 0;
  
@@ -688,7 +704,7 @@
function rcmail_message_body($attrib)
  {
  global $CONFIG, $OUTPUT, $MESSAGE, $IMAP, $REMOTE_OBJECTS;
  if (!is_array($MESSAGE->parts) && empty($MESSAGE->body))
    return '';
    
@@ -719,8 +735,8 @@
          $part->body = $MESSAGE->get_part_content($part->mime_id);
        $body = rcmail_print_body($part, $safe_mode, !$CONFIG['prefer_html']);
        if ($part->ctype_secondary != 'plain')
        if ($part->ctype_secondary == 'html')
          $out .= html::div('message-htmlpart', rcmail_html4inline($body, $attrib['id']));
        else
          $out .= html::div('message-part', $body);
@@ -728,15 +744,19 @@
      }
    }
  else
    $out .= html::div('message-part', html::div('pre', $MESSAGE->body));
    $out .= html::div('message-part', html::div('pre', Q($MESSAGE->body)));
  $ctype_primary = strtolower($MESSAGE->structure->ctype_primary);
  $ctype_secondary = strtolower($MESSAGE->structure->ctype_secondary);
  // list images after mail body
  if (get_boolean($attrib['showimages']) && $ctype_primary == 'multipart' &&
      !empty($MESSAGE->attachments) && !strstr($message_body, '<html')) {
  if (get_boolean($attrib['showimages'])
      && $CONFIG['inline_images']
      && $ctype_primary == 'multipart'
      && !empty($MESSAGE->attachments)
      && !strstr($message_body, '<html'))
    {
    foreach ($MESSAGE->attachments as $attach_prop) {
      if (strpos($attach_prop->mimetype, 'image/') === 0) {
        $out .= html::tag('hr') . html::p(array('align' => "center"),
@@ -1028,18 +1048,18 @@
function rcmail_send_mdn($uid)
{
  global $CONFIG, $USER, $IMAP;
  global $RCMAIL, $IMAP;
  $message = new rcube_message($uid);
  
  if ($message->headers->mdn_to && !$message->headers->mdn_sent)
  {
    $identity = $USER->get_identity();
    $identity = $RCMAIL->user->get_identity();
    $sender = format_email_recipient($identity['email'], $identity['name']);
    $recipient = array_shift($IMAP->decode_address_list($message->headers->mdn_to));
    $mailto = $recipient['mailto'];
    $compose = new rcube_mail_mime(rcmail_header_delm());
    $compose = new rcube_mail_mime($RCMAIL->config->header_delimiter());
    $compose->setParam(array(
      'text_encoding' => 'quoted-printable',
      'html_encoding' => 'quoted-printable',
@@ -1055,21 +1075,21 @@
      'From' => $sender,
      'To'   => $message->headers->mdn_to,
      'Subject' => rcube_label('receiptread') . ': ' . $message->subject,
      'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), rcmail_mail_domain($_SESSION['imap_host'])),
      'Message-ID' => sprintf('<%s@%s>', md5(uniqid('rcmail'.rand(),true)), $RCMAIL->config->mail_domain($_SESSION['imap_host'])),
      'X-Sender' => $identity['email'],
      'Content-Type' => 'multipart/report; report-type=disposition-notification',
    );
    
    if (!empty($CONFIG['useragent']))
      $headers['User-Agent'] = $CONFIG['useragent'];
    if ($agent = $RCMAIL->config->get('useragent'))
      $headers['User-Agent'] = $agent;
    $body = rcube_label("yourmessage") . "\r\n\r\n" .
      "\t" . rcube_label("to") . ': ' . rcube_imap::decode_mime_string($message->headers->to, $message->headers->charset) . "\r\n" .
      "\t" . rcube_label("subject") . ': ' . $message->subject . "\r\n" .
      "\t" . rcube_label("sent") . ': ' . format_date($message->headers->date, $CONFIG['date_long']) . "\r\n" .
      "\t" . rcube_label("sent") . ': ' . format_date($message->headers->date, $RCMAIL->config->get('date_long')) . "\r\n" .
      "\r\n" . rcube_label("receiptnote") . "\r\n";
    
    $ua = !empty($CONFIG['useragent']) ? $CONFIG['useragent'] : "RoundCube Webmail (Version ".RCMAIL_VERSION.")";
    $ua = $RCMAIL->config->get('useragent', "RoundCube Webmail (Version ".RCMAIL_VERSION.")");
    $report = "Reporting-UA: $ua\r\n";
    
    if ($message->headers->to)