Request #9099: Add config option to disable multipart/related conversions
authorMichael M Slusarz <slusarz@curecanti.org>
Mon, 28 Jun 2010 20:29:31 +0000 (14:29 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Mon, 28 Jun 2010 20:29:31 +0000 (14:29 -0600)
imp/config/conf.xml
imp/docs/CHANGES
imp/lib/Compose.php

index 52a5f3e..2e84132 100644 (file)
    <configinteger name="attach_count_limit" desc="What is the maximum total
    number of attachments per message? Set this value to 0 for no
    limit.">0</configinteger>
+   <configboolean name="convert_to_related" desc="When composing a message in
+   HTML mode, should we download the data for any images contained in the
+   message and directly attach to the message? This is highly recommended as
+   the image data may not otherwise be available when the recipient views
+   the message in the future. This should be turned off for servers that are
+   firewalled or otherwise have limited Internet
+   connectivity.">true</configboolean>
    <configinteger name="reply_limit" desc="What is the maximum total size of
    text (in bytes) to use when replying or forwarding a message. Set this value
    to 0 for no limit.">200000</configinteger>
index 8e395c9..1650260 100644 (file)
@@ -2,6 +2,8 @@
 v5.0-git
 --------
 
+[mms] Add config option to disable multipart/related conversions
+      (Request #9099).
 [mms] Sentmail SQL driver now supports split read/write operation.
 [mms] Pass compose message data to mailer backend via stream; much more
       efficient, especially with larger messages (Request #8909).
index 997628a..ca50e05 100644 (file)
@@ -1081,10 +1081,12 @@ class IMP_Compose
             $textpart->setHeaderCharset($charset);
 
             if (empty($options['nofinal'])) {
-                $textpart->addPart($this->_convertToMultipartRelated($htmlBody));
-            } else {
-                $textpart->addPart($htmlBody);
+                try {
+                    $htmlBody = $this->_convertToMultipartRelated($htmlBody);
+                } catch (Horde_Exception $e) {}
             }
+
+            $textpart->addPart($htmlBody);
         } else {
             $textpart = $textBody;
         }
@@ -2258,9 +2260,11 @@ class IMP_Compose
     {
         global $conf;
 
-        /* Return immediately if this is not a HTML part, or no 'img' tags are
+        /* Return immediately if related conversion is turned off via
+         * configuration, this is not a HTML part, or no 'img' tags are
          * found (specifically searching for the 'src' parameter). */
-        if (($mime_part->getType() != 'text/html') ||
+        if (empty($conf['compose']['convert_to_related']) ||
+            ($mime_part->getType() != 'text/html') ||
             !preg_match_all('/<img[^>]+src\s*\=\s*([^\s]+)\s+/iU', $mime_part->getContents(), $results)) {
             return $mime_part;
         }