Index: mimemail.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/mimemail.inc,v
retrieving revision 1.40
diff -u -r1.40 mimemail.inc
--- mimemail.inc	23 Feb 2009 16:11:19 -0000	1.40
+++ mimemail.inc	14 Mar 2010 13:49:05 -0000
@@ -279,6 +279,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'),
@@ -286,31 +287,34 @@
     }
     //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';
+  // Include HTML versions of content only if plaintext is not explicitly set
+  else {
+    $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=")([^"]*)/emi';
-  $body = preg_replace($pattern, '"\\1"._mimemail_url("\2")', $body);
+    //expand all local links
+    $pattern = '/(<a[^>]+href=")([^"]*)/emi';
+    $body = preg_replace($pattern, '"\\1"._mimemail_url("\2")', $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']));
-
-  if ($mime_parts) {
-    $content_type = 'multipart/related';
-    $parts = array_merge($parts, $mime_parts);
-  }
+    $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);
+    }
+  }  
   foreach ($attachments as $a) {
     $a = (object) $a;
     $content_type = 'multipart/mixed';
