Index: mimemail.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/mimemail/mimemail.inc,v
retrieving revision 1.41
diff -u -p -r1.41 mimemail.inc
--- mimemail.inc	24 Mar 2010 21:36:41 -0000	1.41
+++ mimemail.inc	13 Apr 2010 05:20:32 -0000
@@ -153,6 +153,7 @@
 
   $ret = $files;
   $files = array();
+  $filenames = array();
   return $ret;
 }
 
@@ -292,6 +293,7 @@
   if ($plaintext) {
     //Plain mail without attachment
     if (empty($attachments)) {
+      $content_type = 'text/plain';
       return array(
         'body' => $text,
         'headers' => array('Content-Type' => 'text/plain; charset=utf-8'),
@@ -299,31 +301,33 @@
     }
     //Plain mail has attachement
     else {
+      $content_type = 'multipart/mixed';
       $parts = array(array(
       'content' => $text,
         'Content-Type' => 'text/plain; charset=utf-8',
       ));
     }
   }
-  $content_type = 'multipart/alternative';
+  else {   // Include HTML versions of content only if plaintext is not explicitly set
+    $content_type = 'multipart/alternative';
 
-  $text_part = array('Content-Type' => 'text/plain; charset=utf-8', 'content' => $text);
+    $text_part = array('Content-Type' => 'text/plain; charset=utf-8', 'content' => $text);
 
-  //expand all local links
-  $pattern = '/(<a[^>]+href=")([^"]*)/mi';
-  $body = preg_replace_callback($pattern, '_mimemail_expand_links', $body);
+    //expand all local links
+    $pattern = '/(<a[^>]+href=")([^"]*)/mi';
+    $body = preg_replace_callback($pattern, '_mimemail_expand_links', $body);
 
-  $mime_parts = mimemail_extract_files($body);
+    $mime_parts = mimemail_extract_files($body);
 
-  $content = array($text_part, array_shift($mime_parts));
-  $content = mimemail_multipart_body($content, $content_type, TRUE);
-  $parts = array(array('Content-Type' => $content['headers']['Content-Type'], 'content' => $content['body']));
+    $content = array($text_part, array_shift($mime_parts));
+    $content = mimemail_multipart_body($content, $content_type, TRUE);
+    $parts = array(array('Content-Type' => $content['headers']['Content-Type'], 'content' => $content['body']));
 
-  if ($mime_parts) {
-    $content_type = 'multipart/related';
-    $parts = array_merge($parts, $mime_parts);
+    if ($mime_parts) {
+      $content_type = 'multipart/related';
+      $parts = array_merge($parts, $mime_parts);
+    }
   }
-
   foreach ($attachments as $a) {
     $a = (object) $a;
     $content_type = 'multipart/mixed';
