### Eclipse Workspace Patch 1.0
#P webform
Index: includes/webform.admin.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/webform/includes/webform.admin.inc,v
retrieving revision 1.10
diff -u -r1.10 webform.admin.inc
--- includes/webform.admin.inc	7 Jan 2011 20:24:08 -0000	1.10
+++ includes/webform.admin.inc	20 Feb 2011 11:30:52 -0000
@@ -12,6 +12,19 @@
 function webform_admin_settings() {
   module_load_include('inc', 'webform', 'includes/webform.export');
 
+  if (module_exists('mimemail')) {
+    $form['webform_mail_system'] = array(
+      '#type' => 'select',
+      '#title' => t('Mail system'),
+      '#options' => array(
+        'DefaultMailSystem' => t('Default'),
+        'MimeMailSystem' => 'MimeMail',
+      ),
+      '#default_value' => variable_get('webform_mail_system', 'DefaultMailSystem'),
+      '#description' => t('The mail system to use for Webform messages.'),
+    );
+  }
+
   $node_types = node_type_get_names();
   $form['node_types'] = array(
     '#type' => 'checkboxes',
@@ -160,6 +173,14 @@
 }
 
 function webform_admin_settings_submit($form, &$form_state) {
+  // Mime Mail is available, let the user choose which mail system to use.
+  if (module_exists('mimemail')) {
+    $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
+    $webform_system = $form_state['values']['webform_mail_system'];
+    $mail_system['webform'] = $webform_system;
+    variable_set('mail_system', $mail_system);
+  }
+
   $disabled_components = array();
   foreach ($form_state['values']['components'] as $name => $enabled) {
     if (!$enabled) {
Index: includes/webform.submissions.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/webform/includes/webform.submissions.inc,v
retrieving revision 1.36
diff -u -r1.36 webform.submissions.inc
--- includes/webform.submissions.inc	17 Feb 2011 04:08:56 -0000	1.36
+++ includes/webform.submissions.inc	20 Feb 2011 11:30:52 -0000
@@ -281,6 +281,10 @@
       );
 
       if (module_exists('mimemail')) {
+        // Optional params for Mime Mail.
+        $mail_params['plain'] = !$email['html'];
+        $mail_params['plaintext'] = $email['html'] ? NULL : $email['message'];
+        $mail_params['headers'] = $email['headers'];
         // Load attachments for the e-mail.
         $attachments = array();
         if ($email['attachments']) {
@@ -289,25 +293,18 @@
             if (webform_component_feature($component['type'], 'attachment') && !empty($submission->data[$component['cid']]['value'][0])) {
               $file = webform_get_file($submission->data[$component['cid']]['value'][0]);
               if ($file) {
-                $file->list = 1; // Needed to include in attachments.
                 $attachments[] = $file;
               }
             }
           }
         }
-
-        // Send the e-mail via MIME mail.
-        $message = mimemail($email['from'], $address, $email['subject'], $email['message'], !$email['html'], $email['headers'], $email['html'] ? NULL : $email['message'], $attachments, 'webform');
-        if ($message) {
-          $send_count++;
-        }
+        $mail_params['attachments'] = $attachments;
       }
-      else {
-        // Normal Drupal mailer.
-        $message = drupal_mail('webform', 'submission', $address, $language, $mail_params, $email['from']);
-        if ($message['result']) {
-          $send_count++;
-        }
+
+      // Send the message.
+      $message = drupal_mail('webform', 'submission', $address, $language, $mail_params, $email['from']);
+      if ($message['result']) {
+        $send_count++;
       }
     }
   }
