]> git.donarmstrong.com Git - roundcube.git/blobdiff - program/steps/mail/sendmail.inc
Imported Upstream version 0.2~alpha
[roundcube.git] / program / steps / mail / sendmail.inc
index 12dd18a6ceddba4e9358d5f67246fe96d5df174b..8d850eb3c429f49b3efacb8fbb2ee27a469bacff 100644 (file)
@@ -5,7 +5,7 @@
  | program/steps/mail/sendmail.inc                                       |
  |                                                                       |
  | This file is part of the RoundCube Webmail client                     |
- | Copyright (C) 2005-2007, RoundCube Dev. - Switzerland                 |
+ | Copyright (C) 2005-2008, RoundCube Dev. - Switzerland                 |
  | Licensed under the GNU GPL                                            |
  |                                                                       |
  | PURPOSE:                                                              |
  | Author: Thomas Bruederli <roundcube@gmail.com>                        |
  +-----------------------------------------------------------------------+
 
- $Id: sendmail.inc 1120 2008-02-19 23:59:38Z thomasb $
+ $Id: sendmail.inc 1344 2008-04-30 08:21:42Z thomasb $
 
 */
 
 
-//require_once('lib/smtp.inc');
-require_once('lib/html2text.inc');
-require_once('lib/rc_mail_mime.inc');
-
-
 if (!isset($_SESSION['compose']['id']))
   {
   rcmail_overwrite_action('list');
@@ -70,7 +65,7 @@ function rcmail_get_identity($id)
  */
 function rcmail_attach_emoticons(&$mime_message)
 {
-  global $CONFIG, $INSTALL_PATH;
+  global $CONFIG;
 
   $htmlContents = $mime_message->getHtmlBody();
 
@@ -100,7 +95,7 @@ function rcmail_attach_emoticons(&$mime_message)
     if (! in_array($image_name, $included_images))
       {
       // add the image to the MIME message
-      $img_file = $INSTALL_PATH . '/' . $searchstr . $image_name;
+      $img_file = INSTALL_PATH . '/' . $searchstr . $image_name;
       if(! $mime_message->addHTMLImage($img_file, 'image/gif', '', true, '_' . $image_name))
         $OUTPUT->show_message("emoticonerror", 'error');
 
@@ -210,14 +205,18 @@ if (!empty($_POST['_receipt']))
   }
 
 // additional headers
+if ($CONFIG['http_received_header'])
+{
+  $nldlm = rcmail_header_delm() . "\t";
+  $headers['Received'] =  wordwrap('from ' . (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
+      gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']).' ['.$_SERVER['HTTP_X_FORWARDED_FOR'].']'.$nldlm.' via ' : '') .
+    gethostbyaddr($_SERVER['REMOTE_ADDR']).' ['.$_SERVER['REMOTE_ADDR'].']'.$nldlm.'with ' .
+    $_SERVER['SERVER_PROTOCOL'].' ('.$_SERVER['REQUEST_METHOD'].'); ' . date('r'),
+    69, $nldlm);
+}
+
 $headers['Message-ID'] = $message_id;
 $headers['X-Sender'] = $from;
-$headers['Received'] =  wordwrap('from ' .
-  (isset($_SERVER['HTTP_X_FORWARDED_FOR']) ?
-    gethostbyaddr($_SERVER['HTTP_X_FORWARDED_FOR']).' ['.$_SERVER['HTTP_X_FORWARDED_FOR'].'] via ' : '') .
-  gethostbyaddr($_SERVER['REMOTE_ADDR']).' ['.$_SERVER['REMOTE_ADDR'].'] with ' .
-  $_SERVER['SERVER_PROTOCOL'].' ('.$_SERVER['REQUEST_METHOD'].'); ' . date('r'),
-  69, rcmail_header_delm() . "\t");
 
 if (!empty($CONFIG['useragent']))
   $headers['User-Agent'] = $CONFIG['useragent'];
@@ -233,7 +232,7 @@ $isHtmlVal = strtolower(get_input_value('_is_html', RCUBE_INPUT_POST));
 $isHtml = ($isHtmlVal == "1");
 
 // create extended PEAR::Mail_mime instance
-$MAIL_MIME = new rc_mail_mime(rcmail_header_delm());
+$MAIL_MIME = new rcube_mail_mime(rcmail_header_delm());
 
 // For HTML-formatted messages, construct the MIME message with both
 // the HTML part and the plain-text part
@@ -245,6 +244,11 @@ if ($isHtml)
   // add a plain text version of the e-mail as an alternative part.
   $h2t = new html2text($message_body);
   $plainTextPart = wordwrap($h2t->get_text(), 998, "\r\n", true);
+  if (!strlen($plainTextPart)) 
+    { 
+    // empty message body breaks attachment handling in drafts 
+    $plainTextPart = "\r\n"; 
+    }
   $MAIL_MIME->setTXTBody(html_entity_decode($plainTextPart, ENT_COMPAT, 'utf-8'));
 
   // look for "emoticon" images from TinyMCE and copy into message as attachments
@@ -254,6 +258,11 @@ else
   {
   $message_body = wordwrap($message_body, 75, "\r\n");
   $message_body = wordwrap($message_body, 998, "\r\n", true);
+  if (!strlen($message_body))  
+    { 
+    // empty message body breaks attachment handling in drafts 
+    $message_body = "\r\n"; 
+    } 
   $MAIL_MIME->setTXTBody($message_body, FALSE, TRUE);
   }
 
@@ -304,7 +313,7 @@ $MAIL_MIME->setParam(array(
 ));
 
 // encoding subject header with mb_encode provides better results with asian characters
-if ($MBSTRING && function_exists("mb_encode_mimeheader"))
+if (function_exists("mb_encode_mimeheader"))
 {
   mb_internal_encoding($message_charset);
   $headers['Subject'] = mb_encode_mimeheader($headers['Subject'], $message_charset, 'Q');