Index: modules/mimemail_compress/mimemail_compress.info
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/modules/mimemail_compress/mimemail_compress.info,v
retrieving revision 1.1
diff -u -r1.1 mimemail_compress.info
--- modules/mimemail_compress/mimemail_compress.info	22 Feb 2009 21:01:14 -0000	1.1
+++ modules/mimemail_compress/mimemail_compress.info	27 Mar 2010 10:08:45 -0000
@@ -1,6 +1,8 @@
-; $Id: mimemail_compress.info,v 1.1 2009/02/22 21:01:14 vauxia Exp $
-name = Mime Mail CSS Compressor
-description = Converts CSS to inline styles in an HTML message. Requires PHP 5.x and the DOM extension
+; $Id$
+name = "Mime Mail CSS Compressor"
+description = "Converts CSS to inline styles in an HTML message. Requires PHP 5.x and the DOM extension."
 package = Mail
 dependencies[] = mimemail
 core = 6.x
+php = 5
+version = 6.x-1.0-beta1-05
\ No newline at end of file
Index: modules/mimemail_compress/mimemail_compress.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/modules/mimemail_compress/mimemail_compress.inc,v
retrieving revision 1.5
diff -u -r1.5 mimemail_compress.inc
--- modules/mimemail_compress/mimemail_compress.inc	16 Jul 2009 02:12:24 -0000	1.5
+++ modules/mimemail_compress/mimemail_compress.inc	27 Mar 2010 10:08:45 -0000
@@ -1,4 +1,11 @@
-<?php // $Id: mimemail_compress.inc,v 1.5 2009/07/16 02:12:24 jerdavis Exp $
+<?php
+
+// $Id$
+
+/**
+ * @file
+ * Creates inline style definitions from CSS.
+ */
 
 /**
  * Code based on emogrifier by Pelago Design and licensed under the MIT license
@@ -21,8 +28,8 @@
   preg_match('|(<style[^>]+)>(.*)</style>|mis', $message, $matches);
   $css  = str_replace('<!--', '', $matches[2]);
   $css  = str_replace('-->', '', $css);
-  $css = preg_replace('|\{|',"\n{\n", $css);
-  $css = preg_replace('|\}|',"\n}\n", $css);
+  $css = preg_replace('|\{|', "\n{\n", $css);
+  $css = preg_replace('|\}|', "\n}\n", $css);
   $html = str_replace($matches[0], '', $message);
   $parts = array('html' => $html, 'css' => $css);
   return $parts;
@@ -40,8 +47,8 @@
   public function compress() {
     $err = error_reporting(0);
     $doc = new DOMDocument('1.0', 'utf8');
-    $doc->strictErrorChecking = false;
-    $doc->formatOutput = true;
+    $doc->strictErrorChecking = FALSE;
+    $doc->formatOutput = TRUE;
     $doc->loadHTML($this->html);
     $doc->normalizeDocument();
     $xpath = new DOMXPath($doc);
@@ -50,23 +57,23 @@
 
     foreach ($matches[1] as $key => $selector_string) {
       if (!strlen(trim($matches[2][$key]))) continue;
-      $selectors = explode(',',$selector_string);
+      $selectors = explode(',', $selector_string);
       foreach ($selectors as $selector) {
-        if (strpos($selector,':') !== false) continue;
+        if (strpos($selector, ':') !== FALSE) continue;
         $nodes = $xpath->query($this->css_to_xpath(trim($selector)));
-        foreach($nodes as $node) {
+        foreach ($nodes as $node) {
           if ($node->hasAttribute('style')) {
             $style = $node->getAttribute('style');
             $old_style = $this->css_style_to_array($node->getAttribute('style'));
             $new_style = $this->css_style_to_array($matches[2][$key]);
-            $compressed = array_merge($old_style,$new_style);
+            $compressed = array_merge($old_style, $new_style);
             $style = '';
             foreach ($compressed as $k => $v) $style .= ($k . ':' . $v . ';');
           }
           else {
             $style = trim($matches[2][$key]);
           }
-          $node->setAttribute('style',$style);
+          $node->setAttribute('style', $style);
         }
       }
     }
@@ -91,14 +98,14 @@
       "(strlen('\\1') ? '\\1' : '*').'[@id=\"\\2\"]'",
       "(strlen('\\1') ? '\\1' : '*').'[contains(concat(\" \",@class,\" \"),concat(\" \",\"\\2\",\" \"))]'",
     );
-    return '//'.preg_replace($search, $replace, trim($selector));
+    return '//'. preg_replace($search, $replace, trim($selector));
   }
 
   private function css_style_to_array($style) {
-    $definitions = explode(';',$style);
+    $definitions = explode(';', $style);
     $css_styles = array();
     foreach ($definitions as $def) {
-      list($key,$value) = explode(':',$def);
+      list($key, $value) = explode(':', $def);
       if (empty($key) || empty($value)) continue;
       $css_styles[trim($key)] = trim($value);
     }
Index: modules/mimemail_compress/mimemail_compress.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/modules/mimemail_compress/mimemail_compress.module,v
retrieving revision 1.3
diff -u -r1.3 mimemail_compress.module
--- modules/mimemail_compress/mimemail_compress.module	23 Feb 2009 04:28:46 -0000	1.3
+++ modules/mimemail_compress/mimemail_compress.module	27 Mar 2010 10:08:45 -0000
@@ -1,4 +1,6 @@
-<?php // $Id: mimemail_compress.module,v 1.3 2009/02/23 04:28:46 jerdavis Exp $
+<?php 
+
+// $Id$
 
 /**
  * @file
@@ -16,4 +18,4 @@
   $output = new mimemail_compress($parts['html'], $parts['css']);
   $output = $output->compress();
   $message = $output;
-}
+}
\ No newline at end of file
Index: includes/mimemail.admin.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/includes/mimemail.admin.inc,v
retrieving revision 1.1
diff -u -r1.1 mimemail.admin.inc
--- includes/mimemail.admin.inc	22 Feb 2009 20:55:46 -0000	1.1
+++ includes/mimemail.admin.inc	27 Mar 2010 10:08:44 -0000
@@ -1,4 +1,6 @@
-<?php /* $Id: mimemail.admin.inc,v 1.1 2009/02/22 20:55:46 vauxia Exp $ */
+<?php
+
+// $Id$
 
 /**
  * @file
@@ -12,22 +14,21 @@
  *   The administration from.
  */
 function mimemail_admin_settings() {
-
   // override the smtp_library value if mimemail is chosen to handle all mail
   // this will cause drupal_mail to call mimemail()
   if (variable_get('mimemail_alter', 0)) {
-    if (!strpos(variable_get('smtp_library', ''), 'mimemail')) {
+    if (strpos(variable_get('smtp_library', '') === FALSE, 'mimemail')) {
       variable_set('smtp_library', drupal_get_filename('module', 'mimemail'));
     }
   }
   else {
-    if (strpos(variable_get('smtp_library', ''), 'mimemail')) {
+    if (strpos(variable_get('smtp_library', '') !== FALSE, 'mimemail')) {
       db_query("DELETE FROM {variable} WHERE name = 'smtp_library'");
     }
   }
-
+  
   $engines = mimemail_get_engines();
-
+  
   $form = array();
   $form['site_mail'] = array(
     '#type'          => 'textfield',
@@ -37,15 +38,21 @@
     '#maxlength'     => 128,
     '#description'   => t('A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc.')
   );
+  
   $form['mimemail']['mimemail_alter'] = array(
     '#type'          => 'checkbox',
     '#title'         => t('Use mime mail for all messages'),
     '#default_value' => variable_get('mimemail_alter', 0),
-    '#description'   => t('Use the mime mail module to deliver all site messages.  With this option, system emails will have styles and formatting'),
+    '#description'   => t('Use the mime mail module to deliver all site messages. With this option, system emails will have styles and formatting.')
+  );
+  
+  // Optional including of site style sheets
+  $form['mimemail']['mimemail_sitestyle'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Include site style sheets'),
+    '#default_value' => variable_get('mimemail_sitestyle', 0),
+    '#description'   => t('Gather all style sheets when no mail.css found in the default theme directory.'),
   );
-
-  $filter_format = variable_get('mimemail_format', FILTER_FORMAT_DEFAULT);
-  $form['mimemail']['mimemail_format'] =  filter_form($filter_format, NULL, array("mimemail_format"));
 
   $form['mimemail']['mimemail_textonly'] = array(
     '#type'          => 'checkbox',
@@ -53,20 +60,32 @@
     '#default_value' => variable_get('mimemail_textonly', 0),
     '#description'   => t('This option disables the use of email messages with graphics and styles.  All messages will be converted to plain text.'),
   );
+  
+  $filter_format = variable_get('mimemail_format', FILTER_FORMAT_DEFAULT);
+  $form['mimemail']['mimemail_format'] =  filter_form($filter_format, NULL, array("mimemail_format"));
 
-  $form['mimemail']['incoming'] = array(
+  $form['mimemail']['advanced'] = array(
     '#type'          => 'fieldset',
     '#title'         => t('Advanced Settings'),
     '#collapsible'   => TRUE,
     '#collapsed'     => TRUE,
   );
-  $form['mimemail']['incoming']['mimemail_incoming'] = array(
+  
+  $form['mimemail']['advanced']['mimemail_envelope_sender'] = array(
+    '#type'          => 'checkbox',
+    '#title'         => t('Set the envelope sender address'),
+    '#default_value' => variable_get('mimemail_envelope_sender', 0),
+    '#description'   => t('Sets the envelope sender address with the <em>-f</em> sendmail option. This option will not be used if the site is running in <em>safe_mode</em>.'),
+  );
+  
+  $form['mimemail']['advanced']['mimemail_incoming'] = array(
     '#type'          => 'checkbox',
     '#title'         => t('Process incoming messages posted to this site'),
     '#default_value' => variable_get('mimemail_incoming', 0),
     '#description'   => t('This is an advanced setting that should not be enabled unless you know what you are doing'),
   );
-  $form['mimemail']['incoming']['mimemail_key'] = array(
+  
+  $form['mimemail']['advanced']['mimemail_key'] = array(
     '#type'          => 'textfield',
     '#title'         => t('Message validation string'),
     '#default_value' => variable_get('mimemail_key', md5(rand())),
@@ -99,8 +118,8 @@
     $settings = module_invoke(variable_get('mimemail_engine', 'mail'), 'mailengine', 'settings');
     if ($settings) {
         $form['mimemail_engine_settings'] = array(
-          '#type'        => 'fieldset',
-          '#title'       => t('Engine specific settings'),
+          '#type'   => 'fieldset',
+          '#title'  => t('Engine specific settings'),
       );
       foreach ($settings as $name => $value) {
         $form['mimemail_engine_settings'][$name] = $value;
Index: includes/mimemail.incoming.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/includes/mimemail.incoming.inc,v
retrieving revision 1.1
diff -u -r1.1 mimemail.incoming.inc
--- includes/mimemail.incoming.inc	22 Feb 2009 20:55:46 -0000	1.1
+++ includes/mimemail.incoming.inc	27 Mar 2010 10:08:44 -0000
@@ -1,4 +1,6 @@
-<?php /* $Id: mimemail.incoming.inc,v 1.1 2009/02/22 20:55:46 vauxia Exp $ */
+<?php
+
+// $Id$
 
 /**
  * @file
Index: translations/mimemail.pot
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/translations/mimemail.pot,v
retrieving revision 1.1
diff -u -r1.1 mimemail.pot
--- translations/mimemail.pot	20 Sep 2008 23:20:37 -0000	1.1
+++ translations/mimemail.pot	27 Mar 2010 10:08:45 -0000
@@ -1,16 +1,21 @@
-# $Id: mimemail.pot,v 1.1 2008/09/20 23:20:37 jerdavis Exp $
+# $Id$
 #
 # LANGUAGE translation of Drupal (general)
 # Copyright YEAR NAME <EMAIL@ADDRESS>
 # Generated from files:
-#  mimemail.module,v 1.24 2008/03/01 05:11:52 vauxia
-#  mimemail.info,v 1.1 2007/01/05 05:44:09 vauxia
+#  mimemail.module: n/a
+#  includes/mimemail.admin.inc: n/a
+#  mimemail.info,v 1.2 2008/09/21 02:20:56 jerdavis
+#  modules/mimemail_compress/mimemail_compress.info: n/a
+#  includes/mimemail.incoming.inc: n/a
+#  includes/mimemail.rules.inc: n/a
+#  includes/mimemail.rules_forms.inc: n/a
 #
 #, fuzzy
 msgid ""
 msgstr ""
 "Project-Id-Version: PROJECT VERSION\n"
-"POT-Creation-Date: 2008-09-15 14:03+0200\n"
+"POT-Creation-Date: 2010-03-15 13:15-0500\n"
 "PO-Revision-Date: YYYY-mm-DD HH:MM+ZZZZ\n"
 "Last-Translator: NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <EMAIL@ADDRESS>\n"
@@ -19,103 +24,215 @@
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
 
-#: mimemail.module:14 mimemail.info:0
-msgid "Mail"
+#: mimemail.module:43
+msgid "Email settings"
+msgstr ""
+
+#: mimemail.module:49 includes/mimemail.admin.inc:61
+msgid "Plaintext email only"
 msgstr ""
 
-#: mimemail.module:15
+#: mimemail.module:51
+msgid "Check this option if you do not wish to receive email messages with graphics and styles"
+msgstr ""
+
+#: mimemail.module:211;16 mimemail.info:0
+msgid "Mime Mail"
+msgstr ""
+
+#: mimemail.module:214
+msgid "Default mailing engine using drupal_mail()."
+msgstr ""
+
+#: mimemail.module:17
 msgid "HTML E-mail settings"
 msgstr ""
 
-#: mimemail.module:50
+#: mimemail.info:0
+msgid "E-mail with HTML and attachments"
+msgstr ""
+
+#: mimemail.info:0 modules/mimemail_compress/mimemail_compress.info:0
+msgid "Mail"
+msgstr ""
+
+#: includes/mimemail.admin.inc:35
 msgid "E-mail address"
 msgstr ""
 
-#: mimemail.module:54
+#: includes/mimemail.admin.inc:39
 msgid "A valid e-mail address for this website, used by the auto-mailer during registration, new password requests, notifications, etc."
 msgstr ""
 
-#: mimemail.module:58
+#: includes/mimemail.admin.inc:43
 msgid "Use mime mail for all messages"
 msgstr ""
 
-#: mimemail.module:60
+#: includes/mimemail.admin.inc:45
 msgid "Use the mime mail module to deliver all site messages.  With this option, system emails will have styles and formatting"
 msgstr ""
 
-#: mimemail.module:64;143
-msgid "Plaintext email only"
+#: includes/mimemail.admin.inc:51
+msgid "Include site style sheets"
+msgstr ""
+
+#: includes/mimemail.admin.inc:53
+msgid "Gather all style sheets when no mail.css found in the default theme directory."
 msgstr ""
 
-#: mimemail.module:66
+#: includes/mimemail.admin.inc:63
 msgid "This option disables the use of email messages with graphics and styles.  All messages will be converted to plain text."
 msgstr ""
 
-#: mimemail.module:71
+#: includes/mimemail.admin.inc:68
 msgid "Advanced Settings"
 msgstr ""
 
-#: mimemail.module:77
+#: includes/mimemail.admin.inc:74
 msgid "Process incoming messages posted to this site"
 msgstr ""
 
-#: mimemail.module:79
+#: includes/mimemail.admin.inc:76
 msgid "This is an advanced setting that should not be enabled unless you know what you are doing"
 msgstr ""
 
-#: mimemail.module:83
+#: includes/mimemail.admin.inc:80
 msgid "Message validation string"
 msgstr ""
 
-#: mimemail.module:86
+#: includes/mimemail.admin.inc:83
 msgid "This string will be used to validate incoming messages.  It can be anything, but must be used on both sides of the transfer"
 msgstr ""
 
-#: mimemail.module:94;103
+#: includes/mimemail.admin.inc:91;100
 msgid "E-mail engine"
 msgstr ""
 
-#: mimemail.module:97;106
+#: includes/mimemail.admin.inc:94;103
 msgid "Choose an e-mail engine for sending mails from your site."
 msgstr ""
 
-#: mimemail.module:115
+#: includes/mimemail.admin.inc:112
 msgid "Engine specific settings"
 msgstr ""
 
-#: mimemail.module:123
+#: includes/mimemail.admin.inc:120
 msgid "Please choose a mail engine."
 msgstr ""
 
-#: mimemail.module:137
-msgid "Email settings"
+#: includes/mimemail.incoming.inc:25
+msgid "access denied"
 msgstr ""
 
-#: mimemail.module:145
-msgid "Check this option if you do not wish to receive email messages with graphics and styles"
+#: includes/mimemail.incoming.inc:25
+msgid "Authentication error for POST e-mail"
 msgstr ""
 
-#: mimemail.module:258 mimemail.info:0
-msgid "Mime Mail"
+#: includes/mimemail.rules.inc:15
+msgid "Send an HTML mail to a user"
 msgstr ""
 
-#: mimemail.module:261
-msgid "Default mailing engine using drupal_mail()."
+#: includes/mimemail.rules.inc:17 includes/mimemail.rules_forms.inc:52
+msgid "Recipient"
 msgstr ""
 
-#: mimemail.module:312
-msgid "Authentication error for POST e-mail"
+#: includes/mimemail.rules.inc:23
+msgid "Send an HTML mail to an arbitrary mail address"
 msgstr ""
 
-#: mimemail.module:312
-msgid "access denied"
+#: includes/mimemail.rules.inc:28
+msgid "Send an HTML mail to all users of a role"
 msgstr ""
 
-#: mimemail.module:0
-msgid "mimemail"
+#: includes/mimemail.rules.inc:62;105
+msgid "rules"
 msgstr ""
 
-#: mimemail.info:0
-msgid "E-mail with HTML and attachments"
+#: includes/mimemail.rules.inc:62
+msgid "Successfully sent HTML email to %recipient"
+msgstr ""
+
+#: includes/mimemail.rules.inc:105
+msgid "Successfully sent HTML email to the role(s) %roles."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:16
+msgid "Sender"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:18
+msgid "The mail's from address. Leave it empty to use the site-wide configured address."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:22
+msgid "Subject"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:24
+msgid "The mail's subject."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:28
+msgid "HTML message"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:30
+msgid "The message body in HTML format."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:34
+msgid "Text message"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:36
+msgid "Optional plaintext portion of a multipart e-mail."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:40
+msgid "Attachments"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:42
+msgid "A list of attachments, one file per line. The format of each line is \"[mimetype]:[path]\", e.g. \"image/png:files/images/mypic.png\""
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:54
+msgid "The mail's recipient address. You may separate multiple addresses with comma."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:60
+msgid "CC Recipient"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:62
+msgid "The mail's carbon copy address. You may separate multiple addresses with comma."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:68
+msgid "BCC Recipient"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:70
+msgid "The mail's blind carbon copy address. You may separate multiple addresses with comma."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:86
+msgid "Recipient roles"
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:87
+msgid "WARNING: This may cause problems if there are too many users of these roles on your site, as your server may not be able to handle all the mail requests all at once."
+msgstr ""
+
+#: includes/mimemail.rules_forms.inc:91
+msgid "Select the roles whose users should receive this email."
+msgstr ""
+
+#: modules/mimemail_compress/mimemail_compress.info:0
+msgid "Mime Mail CSS Compressor"
+msgstr ""
+
+#: modules/mimemail_compress/mimemail_compress.info:0
+msgid "Converts CSS to inline styles in an HTML message. Requires PHP 5.x and the DOM extension"
 msgstr ""
 
Index: mimemail.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/mimemail.install,v
retrieving revision 1.1
diff -u -r1.1 mimemail.install
--- mimemail.install	3 Aug 2008 07:16:07 -0000	1.1
+++ mimemail.install	27 Mar 2010 10:08:44 -0000
@@ -1,7 +1,14 @@
-<?php /* $Id: mimemail.install,v 1.1 2008/08/03 07:16:07 jerdavis Exp $ */
+<?php 
+
+// $Id$
 
 /**
- * Implementation of hook_uninstall()
+ * @file
+ * Install, update and uninstall functions for the Mime Mail module.
+ */
+
+/**
+ * Implementation of hook_uninstall().
  */
 function mimemail_uninstall() {
   $variables = array(
@@ -11,9 +18,9 @@
     'mimemail_incoming',
     'mimemail_key',
     'mimemail_textonly',
+    'mimemail_sitestyle',
   );
   foreach ($variables as $variable) {
     variable_del($variable);
   }
-}
-
+}
\ No newline at end of file
Index: mimemail.info
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/mimemail.info,v
retrieving revision 1.2
diff -u -r1.2 mimemail.info
--- mimemail.info	21 Sep 2008 02:20:56 -0000	1.2
+++ mimemail.info	27 Mar 2010 10:08:44 -0000
@@ -1,5 +1,6 @@
-; $Id: mimemail.info,v 1.2 2008/09/21 02:20:56 jerdavis Exp $
-name = Mime Mail
-description = E-mail with HTML and attachments
+; $Id$
+name = "Mime Mail"
+description = "HTML e-mail embedded images and attachments."
 package = Mail
-core = 6.x
\ No newline at end of file
+core = 6.x
+version = 6.x-1.0-beta1-05
\ No newline at end of file
Index: README.txt
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/README.txt,v
retrieving revision 1.1
diff -u -r1.1 README.txt
--- README.txt	17 Nov 2005 02:56:38 -0000	1.1
+++ README.txt	27 Mar 2010 10:08:43 -0000
@@ -12,20 +12,35 @@
   useful by itself. Once installed, any module can send messages by 
   calling the mimemail() function:
 	
-	$sender     - a user object or email address
-	$recipient  - a user object or email address
-	$subject    - subject line
-	$body       - body text in html format
-	$plaintext  - boolean, whether to send messages in plaintext-only
-	            (default false)
+	$sender      - a user object, text email address or an array with name, mail
+	$recipient   - a user object, text email address or an array with name, mail
+	$subject     - subject line
+	$body        - body text in html format
+	$plaintext   - boolean, whether to send messages in plaintext-only
+	               (default false)
+	$headers     - a keyed array with headers (optional)
+  $text        - plaintext portion of a multipart e-mail (optional)
+  $attachments - array of arrays with the file's path and MIME type (optional)
+  $mailkey     - message identifier
+  
+  return       - an array containing the MIME encoded message
 
   This module creates a user preference for receiving plaintext-only
-  messages.  This preference will be honored by all calls to mimemail()
+  messages. This preference will be honored by all calls to mimemail()
+  
+  Email messages are formatted using the mimemail.tpl.php template. This
+  includes a css style sheet and uses a compresses HTML version of the text.
+  The included CSS is:
+    the mail.css file found in your default theme
+    of the combined CSS style sheets of your default theme.
   
-  Messages are formatting using theme_mimemail_message($body), which
-  includes all css files from the currently active theme and compresses
-  the HTML version of the text.  Create a new theme function if your 
-  web stylesheets are too heavy for this.
+  To create a custom email template copy the mimemail.tpl.php file from the
+  mimemail/theme directory into your default template folder. If you are using
+  a different administration theme than your default theme, you have to place
+  the mimemail.tpl.php into that theme folder.
+
+  To embed images into emails you have to use relative paths. Images with
+  absolute path will be available as remote content.
   
 CREDITS
 
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	27 Mar 2010 10:08:44 -0000
@@ -1,5 +1,6 @@
 <?php
-/* $Id: mimemail.inc,v 1.40 2009/02/23 16:11:19 jerdavis Exp $ */
+
+// $Id$
 
 /**
  * @file
@@ -24,7 +25,7 @@
     $value = preg_replace('/(\s+|\n|\r|^\s|\s$)/', ' ', $value);
 
     //fold headers if they're too long
-    if (strlen($value) > 60) {
+    if (drupal_strlen($value) > 60) {
       //if there's a semicolon, use that to separate
       if (count($array = preg_split('/;\s*/', $value)) > 1) {
         $value = trim(join(";$crlf    ", $array));
@@ -56,7 +57,7 @@
 
   // Run all headers through mime_header_encode() to convert non-ascii
   // characters to an rfc compliant string, similar to drupal_mail().
-  foreach($headers as $key => $value) {
+  foreach ($headers as $key => $value) {
     $headers[$key] = mime_header_encode($value);
   }
 
@@ -84,9 +85,8 @@
  *                  )
  */
 function mimemail_extract_files($html) {
-  $pattern = '/(<link[^>]+href=[\'"]?|<object[^>]+codebase=[\'"]?|@import |src=[\'"]?)([^\'>"]+)([\'"]?)/emis';
-  $replace = 'stripslashes("\\1")._mimemail_file("\\2").stripslashes("\\3")';
-  $html = preg_replace($pattern, $replace, $html);
+  $pattern = '/(<link[^>]+href=[\'"]?|<object[^>]+codebase=[\'"]?|@import |src=[\'"]?)([^\'>"]+)([\'"]?)/mis';
+  $html = preg_replace_callback($pattern, '_mimemail_replace_files', $html);
 
   $document = array(array(
     'Content-Type' => "text/html; charset=utf-8",
@@ -100,6 +100,13 @@
 }
 
 /**
+ * Callback for preg_replace_callback()
+ */
+function _mimemail_replace_files($matches) {
+  return stripslashes($matches[1]) . _mimemail_file($matches[2]) . stripslashes($matches[3]);
+}
+
+/**
  * Helper function to extract local files
  *
  * @param $url a URL to a file
@@ -112,41 +119,51 @@
 
   if ($url) {
     $url = _mimemail_url($url, 'TRUE');
-
     // If the $url is absolute, we're done here.
-    if (strpos($url, '://') || preg_match('!mailto:!', $url)) {
+    if (strpos($url, '://') !== FALSE || preg_match('!mailto:!', $url)) {
       return $url;
     }
-    else {
     // The $url is a relative file path, continue processing.
-      $file = $url;
+    else {
+      // Check if download method is set to private.
+      if (variable_get('file_downloads', '') == FILE_DOWNLOADS_PRIVATE && strpos($url, 'system/files/') !== FALSE) {
+        $file = file_create_path(drupal_substr($url, (strpos($url, 'system/files/') + drupal_strlen('system/files/'))));
+      }
+      // Download method is public.
+      else {
+        $file = $url;
+      }
     }
   }
 
-  if ($file && file_exists($file)) {
-    // Prevent duplicate items
-    if (isset($filenames[$file])) return 'cid:'. $filenames[$file];
-    
-    $content_id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
-
-    if (!$name) $name = substr($file, strrpos($file, '/') + 1);
-
-    $new_file = array(
-      'name' => $name,
-      'file' => $file,
-      'Content-ID' => $content_id,
-      'Content-Disposition' => $disposition,
-    );
-    $new_file['Content-Type'] = file_get_mimetype($file);
-
-    $files[] = $new_file;
-    $filenames[$file] = $content_id;
-
-    return 'cid:'. $content_id;
+  if (isset($file)) {
+    if (@file_exists($file)) {
+      // Prevent duplicate items
+      if (isset($filenames[$file])) return 'cid:'. $filenames[$file];
+      
+      $content_id = md5($file) .'@'. $_SERVER['HTTP_HOST'];
+      
+      if (!$name) $name = drupal_substr($file, strrpos($file, '/') + 1);
+      
+      $new_file = array(
+        'name' => $name,
+        'file' => $file,
+        'Content-ID' => $content_id,
+        'Content-Disposition' => $disposition,
+      );
+      
+      $new_file['Content-Type'] = (!empty($name)) ? file_get_mimetype($name) : file_get_mimetype($file);
+      
+      $files[] = $new_file;
+      $filenames[$file] = $content_id;
+      
+      return 'cid:'. $content_id;
+    }
   }
-
+  
   $ret = $files;
   $files = array();
+  $filenames = array();
   return $ret;
 }
 
@@ -210,7 +227,7 @@
       $part_headers['Content-Disposition'] = 'inline';
     }
 
-    if ($part['Content-Transfer-Encoding']) {
+    if (isset($part['Content-Transfer-Encoding'])) {
       $part_headers['Content-Transfer-Encoding'] = $part['Content-Transfer-Encoding'];
     }
 
@@ -240,8 +257,10 @@
         $part_headers['Content-Type'] .= '; name="'. $part['name'] .'"';
         $part_headers['Content-Disposition'] .= '; filename="'. $part['name'] .'"';
       }
-
-      $part_body = chunk_split(base64_encode(file_get_contents($part['file'])));
+      
+      if (isset($part['file'])) {
+        $part_body = chunk_split(base64_encode(file_get_contents($part['file'])));
+      }
     }
 
     $body .= "\n--$boundary\n";
@@ -254,6 +273,13 @@
 }
 
 /**
+ * Callback for preg_replace_callback()
+ */
+function _mimemail_expand_links($matches) {
+  return $matches[1] . _mimemail_url($matches[2]);
+}
+
+/**
  * Generate a multipart message body with a text alternative for some html text
  * @param $body An HTML message body
  * @param $subject The message subject
@@ -277,45 +303,61 @@
     $text = drupal_html_to_text($text);
   }
   if ($plaintext) {
-    //Plain mail without attachment
-    if (empty($attachments)) {
+    // Check if mail has listed attachment
+    if (!empty($attachments)) {
+      foreach ($attachments as $a) {
+        $a = (object) $a;
+        if ($a->list) {
+          $has_attachment = TRUE;
+          break;
+        }
+      }
+    }
+    // Plain mail has attachment
+    if ($has_attachment) {
+      $content_type = 'multipart/mixed';
+      $parts = array(
+        array(
+          'content' => $text,
+          'Content-Type' => 'text/plain; charset=utf-8',
+        ));
+    }
+    // Plain mail without attachement
+    else {
+      $content_type = 'text/plain';
       return array(
         'body' => $text,
         'headers' => array('Content-Type' => 'text/plain; charset=utf-8'),
       );
     }
-    //Plain mail has attachement
-    else {
-      $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/related; 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=")([^"]*)/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, 'multipart/alternative', 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) {
+      $parts = array_merge($parts, $mime_parts);
+    }
   }
-
+  
   foreach ($attachments as $a) {
     $a = (object) $a;
-    $content_type = 'multipart/mixed';
-    _mimemail_file($a->filepath, $a->filename, $a->filemime, 'attachment');
-    $parts = array_merge($parts, _mimemail_file());
+    if ($a->list) {
+      _mimemail_file($a->filepath, $a->filename, $a->filemime, 'attachment');
+      $parts = array_merge($parts, _mimemail_file());
+    }
   }
 
   return mimemail_multipart_body($parts, "$content_type; charset=utf-8");
@@ -327,7 +369,7 @@
   $mail = mimemail_parse_headers($message);
 
   // Get an address-only version of "From" (useful for user_load() and such).
-  $mail['from'] = preg_replace('/.*\b([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4})\b.*/i', '\1', strtolower($mail['headers']['From']));
+  $mail['from'] = preg_replace('/.*\b([a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4})\b.*/i', '\1', drupal_strtolower($mail['headers']['From']));
 
   // Get a subject line, which may be cleaned up/modified later.
   $mail['subject'] = $mail['headers']['Subject'];
@@ -420,8 +462,8 @@
   $headers = array();
   foreach (explode("\n", trim($hdr)) as $row) {
     $split = strpos( $row, ':' );
-    $name = trim(substr($row, 0, $split));
-    $val  = trim(substr($row, $split+1));
+    $name = trim(drupal_substr($row, 0, $split));
+    $val  = trim(drupal_substr($row, $split+1));
     $headers[$name] = $val;
   }
 
@@ -437,7 +479,7 @@
   $content = $part['body'];
 
   // Decode this part
-  if ($encoding = strtolower($part['headers']['Content-Transfer-Encoding'])) {
+  if ($encoding = drupal_strtolower($part['headers']['Content-Transfer-Encoding'])) {
     switch ($encoding) {
 
       case 'base64':
@@ -493,7 +535,7 @@
   $url = urldecode($url);
 
   // If the URL is absolute or a mailto, return it as-is.
-  if (strpos($url, '://') || preg_match('!mailto:!', $url)) {
+  if (strpos($url, '://') !== FALSE || preg_match('!mailto:!', $url)) {
     $url = str_replace(' ', '%20', $url);
     return $url;
   }
Index: mimemail.module
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/mimemail.module,v
retrieving revision 1.46
diff -u -r1.46 mimemail.module
--- mimemail.module	20 May 2009 23:37:26 -0000	1.46
+++ mimemail.module	27 Mar 2010 10:08:44 -0000
@@ -1,4 +1,6 @@
-<?php /* $Id: mimemail.module,v 1.46 2009/05/20 23:37:26 vauxia Exp $ */
+<?php
+
+// $Id$
 
 /**
  * @file
@@ -6,7 +8,7 @@
  */
 
 /**
- * Implementation of hook_menu()
+ * Implementation of hook_menu().
  */
 function mimemail_menu() {
   $path = drupal_get_path('module', 'mimemail') .'/includes';
@@ -66,7 +68,7 @@
  *
  * This function first determines the mail engine to use, then prepares the
  * message by calling the mail engine's prepare function, or
- * mimemail_prepare() if another one does not exist, then sends the message.
+ * mimemail_prepare_message() if another one does not exist, then sends the message.
  *
  * @param $sender
  *   The email address or user object who is sending the message.
@@ -100,7 +102,7 @@
  * @return
  *   An array containing the MIME encoded message, including headers and body.
  */
-function mimemail_prepare($sender, $recipient, $subject, $body, $plaintext = NULL, $headers = array(), $text = NULL, $attachments = array(), $mailkey = '') {
+function mimemail_prepare_message($sender, $recipient, $subject, $body, $plaintext = NULL, $headers = array(), $text = NULL, $attachments = array(), $mailkey = '') {
   module_load_include('inc', 'mimemail');
 
   if (is_null($sender)) {        // use site default for sender
@@ -124,8 +126,10 @@
       }
     }
   }
-  $subject = mime_header_encode(trim(drupal_html_to_text($subject)));
-  $body = theme('mimemail_message', $body, $mailkey);
+  
+  $subject = trim(drupal_html_to_text($subject));
+  $body = theme(array('mimemail_message__'. $mailkey, 'mimemail_message'), $subject, $body, $mailkey);
+  
   foreach (module_implements('mail_post_process') as $module) {
     $function = $module .'_mail_post_process';
     $function($body, $mailkey);
@@ -133,6 +137,7 @@
 
   $plaintext = $plaintext || variable_get('mimemail_textonly', 0);
   $sender    = mimemail_address($sender);
+  $subject   = mime_header_encode($subject);
   $mail      = mimemail_html_body($body, $subject, $plaintext, $text, $attachments);
   $headers   = array_merge($headers, $mail['headers']);
   $message   = array(
@@ -154,21 +159,12 @@
     return FALSE;
   }
 
-  // Allow modules implementing hook_mail_alter() to function when all
-  // mail is routed through mimemail.
-  //  - doesn't support passing all the variables used here (e.g. attachements)
-  //  - should also provide a hook_mimemail_alter for full mimemail support
-  foreach (module_implements('mail_alter') as $module) {
-    $function = $module .'_mail_alter';
-    $function($mailkey, $recipient, $subject, $body, $sender, $headers);
-  }
-
-  $engine_prepare = variable_get('mimemail_engine', 'mimemail') .'_prepare';
-  if (function_exists($engine_prepare)) {
-    $message = $engine_prepare($sender, $recipient, $subject, $body, $plaintext, $headers, $text, $attachments, $mailkey);
+  $engine_prepare_message = variable_get('mimemail_engine', 'mimemail') .'_prepare_message';
+  if (function_exists($engine_prepare_message)) {
+    $message = $engine_prepare_message($sender, $recipient, $subject, $body, $plaintext, $headers, $text, $attachments, $mailkey);
   }
   else {
-    $message = mimemail_prepare($sender, $recipient, $subject, $body, $plaintext, $headers, $text, $attachments, $mailkey);
+    $message = mimemail_prepare_message($sender, $recipient, $subject, $body, $plaintext, $headers, $text, $attachments, $mailkey);
   }
 
   return $engine('send', $message);
@@ -226,19 +222,34 @@
     case 'multiple':
     case 'single':
     case 'send':
-      if (!is_array($message['address'])) {
-        $message['address'] = array($message['address']);
-      }
       $status = TRUE;
-      foreach ($message['address'] as $a) {
-        $status = mail(
-          $a,
-          $message['subject'],
-          $message['body'],
-          mimemail_rfc_headers($message['headers'])
-        ) && $status;
-
+      $subject = $message['subject'];
+      $body = $message['body'];
+      $headers = $message['headers'];
+      $address = (!is_array($message['address'])) ? array($message['address']) : $message['address'];
+    
+      if (variable_get('mimemail_envelope_sender', 0) && 
+          !ini_get('safe_mode') && isset($headers['Return-Path'])) {
+        // If no explicit Return-path set, use From header and add Return-Path.
+        $return_path = '-f'. preg_replace('/(.*<)?(.*?)>?/', "$2", $headers['Return-Path']);
+        foreach ($address as $to) {
+          preg_match('/<([^<>@]+@[^<>@]+)>/', $to, $formatted_address);
+          if (!empty($formatted_address)) {
+            $to = $formatted_address[1];
+          }
+          $status = mail($to, $subject, $body, mimemail_rfc_headers($headers), $return_path) && $status;
+        }
       }
+      else {
+        foreach ($address as $to) {
+          preg_match('/<([^<>@]+@[^<>@]+)>/', $to, $formatted_address);
+          if (!empty($formatted_address)) {
+            $to = $formatted_address[1];
+          }
+          $status = mail($to, $subject, $body, mimemail_rfc_headers($headers)) && $status;
+        }
+      }
+
       return $status;
   }
 
@@ -263,14 +274,14 @@
  * @return
  *   Returns the resultss of the call to mimemail().
  */
-if (strpos(variable_get('smtp_library', ''), 'mimemail')
+if (strpos(variable_get('smtp_library', ''), 'mimemail') !== FALSE
   && !function_exists('drupal_mail_wrapper')) {
 
   function drupal_mail_wrapper(&$message) {
     $from = $message['from'];
     $to = $message['to'];
     $subject = $message['subject'];
-    if (preg_match('/plain/',$message['headers']['Content-Type'])) {
+    if (preg_match('/plain/', $message['headers']['Content-Type'])) {
       $format = variable_get('mimemail_format', FILTER_FORMAT_DEFAULT);
       $body = check_markup($message['body'], $format, FALSE);
     }
@@ -278,7 +289,7 @@
       $body = $message['body'];
     }
     $headers = isset($message['headers']) ? $message['headers'] : array();
-    $mailkey = isset($message['mailkey']) ? $message['mailkey'] : '';
+    $mailkey = isset($message['id']) ? $message['id'] : '';
     return mimemail($from, $to, $subject, $body, NULL, $headers, NULL, array(), $mailkey);
   }
 }
Index: theme/mimemail.theme.inc
===================================================================
RCS file: /cvs/drupal/contributions/modules/mimemail/theme/mimemail.theme.inc,v
retrieving revision 1.2
diff -u -r1.2 mimemail.theme.inc
--- theme/mimemail.theme.inc	10 Aug 2009 17:53:39 -0000	1.2
+++ theme/mimemail.theme.inc	27 Mar 2010 10:08:45 -0000
@@ -1,13 +1,19 @@
-<?php // $Id: mimemail.theme.inc,v 1.2 2009/08/10 17:53:39 vauxia Exp $
+<?php
+
+// $Id$
+
+/**
+ * @file
+ * Theme functions, which control the output of the HTML e-mail.
+ */
 
 function mimemail_theme_theme() {
   $path = drupal_get_path('module', 'mimemail') .'/theme';
-
   return array(
     'mimemail_message' => array(
-      'arguments' => array('body' => NULL, 'mailkey' => NULL),
-      'template' => 'mimemail',
-      'pattern' => 'mimemail__',
+      'arguments' => array('subject' => NULL, 'body' => NULL, 'mailkey' => NULL),
+      'template' => 'mimemail-message',
+      'pattern' => 'mimemail_message__',
       'file' => 'mimemail.theme.inc',
       'path' => $path,
     )
@@ -18,30 +24,76 @@
  * A preprocess function for theme('mimemail_message').
  *
  * The $variables array initially contains the following arguments:
+ * - $subject:  The message subject
  * - $body:  The message body
  * - $mailkey:  The mailkey associated with the message
  *
- * See includes/mimemail.tpl.php for additional variables
+ * See theme/mimemail-message.tpl.php for additional variables
  */
 function template_preprocess_mimemail_message(&$variables) {
-  $theme = variable_get('theme_default', NULL);
-
-  // Check for the existence of a mail.css file in the current theme folder
-  if (!file_exists($styles)) {
-    $styles = drupal_get_path('theme', $theme) .'/mail.css';
+  //Fetch the theme for the current domain
+  if (module_exists('domain'))  {
+    // Assign the theme selected, based on the active domain.
+    global $_domain;
+    $theme = domain_theme_lookup($_domain['domain_id']);
+    // The above returns -1 on failure.
+    if ($theme != -1) {
+      $theme = $theme['theme'];
+    }
+  }
+  else {
+    $theme = variable_get('theme_default', NULL);
   }
 
-  // If no mail.css was found, gather all style sheets
-  if (!file_exists($styles)) {
-    // embed a version of all style definitions
-    $styles = preg_replace('|<link.*href="'. base_path()
-                           .'([^"?]*)[?"].*|', '\1', drupal_get_css());
+  $path_to_theme =  drupal_get_path('theme', $theme);
+
+  $mailkeystyle = $path_to_theme .'/mail-'. $variables['mailkey'] .'.css';
+  $mailstyle = $path_to_theme .'/mail.css';
+
+  // Check if site style sheets including is enabled
+  $sitestyle = variable_get('mimemail_sitestyle', 0);
+
+  // Look for a mail-<mailkey>.css in the default theme folder
+  if (isset($variables['mailkey']) && @file_exists($mailkeystyle)) {
+    $styles = $mailkeystyle;
+  }
+  // If mailkey doesn't found look for a mail.css
+  elseif (@file_exists($mailstyle)) {
+    $styles = $mailstyle;
+  }
+  // Otherwise use site style sheets if enabled
+  elseif ($sitestyle) {
+    // Gather all style sheets, but remove the ones with print media selector
+    $patterns = array('|<link.*media="print"*([^"?]*)[?"].*|',
+                      '|<link.*href="'. base_path() .'([^"?]*)[?"].*|');
+    $replaces = array('', '\1');
+    $styles = preg_replace($patterns, $replaces, drupal_get_css());
   }
 
   // Process each style sheet
   foreach (explode("\n", $styles) as $style) {
-    if (file_exists($style)) $css .= file_get_contents($style);
+    if (!empty($style) && @file_exists($style)) {
+      $css .= file_get_contents($style);
+    }
   }
-
-  $variables['css'] = str_replace(' ','', str_replace("\n", '', $css));
+  
+  // Replace new lines between ids and classes to single space
+  $css = preg_replace(array('#\s+#', '.\s+.'), ' ', $css);
+  // Remove comments
+  $css = preg_replace('#/\*.*?\*/#s', '', $css );
+  // Remove tabs, spaces, new lines, etc.
+  $css = str_replace(array("\r\n", "\r", "\n", "\t", '  ', '    ', '    '), '', $css);
+  // Remove unnecessary spaces
+  $css = str_replace('{ ', '{', $css);
+  $css = str_replace(' }', '}', $css);
+  $css = str_replace('; ', ';', $css);
+  $css = str_replace(', ', ',', $css);
+  $css = str_replace(' {', '{', $css);
+  $css = str_replace('} ', '}', $css);
+  $css = str_replace(': ', ':', $css);
+  $css = str_replace(' ,', ',', $css);
+  $css = str_replace(' ;', ';', $css);
+  // Wordwrap to adhere to RFC821
+  $css = wordwrap($css, 700);
+  $variables['css'] = $css;
 }
Index: theme/mimemail.tpl.php
===================================================================
RCS file: theme/mimemail.tpl.php
diff -N theme/mimemail.tpl.php
--- theme/mimemail.tpl.php	10 Aug 2009 17:53:39 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-<?php // $Id: mimemail.tpl.php,v 1.2 2009/08/10 17:53:39 vauxia Exp $
-
-/**
- * @file mimemail.tpl.php
- */
-?>
-<html>
-  <head>
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
-    <?php if ($css): ?>
-    <style type="text/css">
-      <!--
-      <?php print $css ?>
-      -->
-    </style>
-    <?php endif; ?>
-  </head>
-  <body id="mimemail-body">
-    <div id="center">
-      <div id="main">
-        <?php print $body ?>
-      </div>
-    </div>
-  </body>
-</html>
Index: includes/mimemail.rules.inc
===================================================================
RCS file: includes/mimemail.rules.inc
diff -N includes/mimemail.rules.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/mimemail.rules.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,148 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Rules actions for sending Mime-encoded emails.
+ */
+
+/**
+ * Implementation of hook_rules_action_info().
+ */
+function mimemail_rules_action_info() {
+  return array(
+    'mimemail_rules_action_mail_to_user' => array(
+      'label' => t('Send an HTML mail to a user'),
+      'arguments' => array(
+        'user' => array('type' => 'user', 'label' => t('Recipient')),
+      ),
+      'module' => 'Mime Mail',
+      'eval input' => array('from', 'to', 'cc', 'bc', 'subject', 'message_html', 'message_plaintext', 'attachments'),
+    ),
+    'mimemail_rules_action_mail' => array(
+      'label' => t('Send an HTML mail to an arbitrary mail address'),
+      'module' => 'Mime Mail',
+      'eval input' => array('from', 'to', 'cc', 'bc', 'subject', 'message_html', 'message_plaintext', 'attachments'),
+    ),
+    'mimemail_rules_action_mail_to_users_of_role' => array(
+      'label' => t('Send an HTML mail to all users of a role'),
+      'module' => 'Mime Mail',
+      'eval input' => array('from', 'to', 'cc', 'bc', 'subject', 'message_html', 'message_plaintext', 'attachments'),
+    ),
+  );
+}
+
+/**
+ * Action Implementation: Send a mail to a user and to an arbitrary mail address.
+ */
+function mimemail_rules_action_mail_to_user($user, $settings) {
+  // If $user is empty set acting user
+  if (empty($user)) {
+    global $user;
+  }
+
+  // Validate settings
+  $settings = mimemail_rules_form_settings_validate($settings);
+
+  // If recipient field is empty send it to given user object. if not it's the acting user.
+  $to = empty($settings['to']) ? $user->mail : implode(',', $settings['to']);
+
+  $headers = array(
+    'Bcc' => isset($settings['bc']) ? implode(',', $settings['bc']) : '',
+    'Cc' => isset($settings['cc']) ? implode(',', $settings['cc']) : '',
+  );
+
+  $status = mimemail($settings['from'], $to, $settings['subject'],
+    $settings['message_html'], NULL, $headers, $settings['message_plaintext'],
+    $settings['attachments']
+  );
+
+  if (!empty($status)) {
+    $all_recipients = array_merge(explode(',', $to), $settings['bc'], $settings['cc']);
+    watchdog('rules', 'Successfully sent HTML email to %recipient', array(
+      '%recipient' => implode(', ', $all_recipients),
+    ));
+  }
+}
+
+/**
+ * Action Implementation: rules_action_mail
+ * This action makes use of the rules_action_mail_to_user action implementation.
+ */
+function mimemail_rules_action_mail($settings) {
+  mimemail_rules_action_mail_to_user(NULL, $settings);
+}
+
+/**
+ * Action: Send mail to all users of a specific role group(s).
+ */
+function mimemail_rules_action_mail_to_users_of_role($settings) {
+  $recipients = array_filter(array_keys(array_filter($settings['recipients'])));
+
+  // All authenticated users, which is everybody.
+  if (in_array(DRUPAL_AUTHENTICATED_RID, $recipients)) {
+    $result = db_query('SELECT mail FROM {users} WHERE uid > 0');
+  }
+  else {
+    $rids = implode(',', $recipients);
+    // Avoid sending emails to members of two or more target role groups.
+    $result = db_query('SELECT DISTINCT u.mail FROM {users} u INNER JOIN {users_roles} r ON u.uid = r.uid WHERE r.rid IN ('. $rids .')');
+  }
+
+  // Validate settings
+  $settings = mimemail_rules_form_settings_validate($settings);
+  
+  // Now, actually send the mails.
+  $status = TRUE;
+  while (($account = db_fetch_object($result)) && !empty($status)) {
+    $status = mimemail($settings['from'], $account->mail, $settings['subject'],
+      $settings['message_html'], NULL, array(), $settings['message_plaintext'],
+      $settings['attachments']
+    );
+  }
+  if (!empty($status)) {
+    $roles = array_intersect_key(user_roles(TRUE), drupal_map_assoc($recipients));
+    watchdog('rules', 'Successfully sent HTML email to the role(s) %roles.', array('%roles' => implode(', ', $roles)));
+  }
+}
+
+/*
+ * Helper function for validating form settings on execution time, so that tokens/input evaluators apply
+ */
+function mimemail_rules_form_settings_validate($settings) {
+  // We also handle $settings['to'] and co if it's set.
+  $settings['to'] = empty($settings['to']) ? array() : explode(',', $settings['to']);
+  $settings['cc'] = empty($settings['cc']) ? array() : explode(',', $settings['cc']);
+  $settings['bc'] = empty($settings['bc']) ? array() : explode(',', $settings['bc']);
+
+  foreach ($settings['to'] as $key => $address) {
+    $settings['to'][$key] = str_replace(array("\r", "\n"), '', trim($address));
+  }
+  foreach ($settings['cc'] as $key => $address) {
+    $settings['cc'][$key] = str_replace(array("\r", "\n"), '', trim($address));
+  }
+  foreach ($settings['bc'] as $key => $address) {
+    $settings['bc'][$key] = str_replace(array("\r", "\n"), '', trim($address));
+  }
+  
+  $settings['from'] = str_replace(array("\r", "\n"), '', $settings['from']);
+  $settings['subject'] = str_replace(array("\r", "\n"), '', $settings['subject']);
+  $settings['message_html'] = str_replace(array("\r", "\n"), '', $settings['message_html']);
+  $settings['message_plaintext'] = str_replace(array("\r", "\n"), '', $settings['message_plaintext']);
+  
+  $attachments = array();
+  $attachments_string = trim($settings['attachments']);
+  if (!empty($attachments_string)) {
+    $attachment_lines = array_filter(explode("\n", trim($attachments_string)));
+    foreach ($attachment_lines as $key => $attachment_line) {
+      $attachment = explode(":", trim($attachment_line), 2);
+      $attachments[] = array(
+        'filepath' => $attachment[1],
+        'filemime' => $attachment[0],
+      );
+    }
+  }
+  $settings['attachments'] = empty($attachments[0]['filepath']) ? array() : $attachments;
+  
+  return $settings;
+}
Index: includes/mimemail.rules_forms.inc
===================================================================
RCS file: includes/mimemail.rules_forms.inc
diff -N includes/mimemail.rules_forms.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ includes/mimemail.rules_forms.inc	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,95 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Rules actions for sending Mime-encoded emails (settings forms).
+ */
+
+/**
+ * Action "Send an HTML mail to a user" configuration form
+ */
+function mimemail_rules_action_mail_to_user_form($settings = array(), &$form) {
+  $settings += array('from' => '', 'subject' => '', 'message' => '', 'message_html' => '', 'message_plaintext' => '', 'attachments' => '');
+  $form['settings']['from'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Sender'),
+    '#default_value' => $settings['from'],
+    '#description' => t("The mail's from address. Leave it empty to use the site-wide configured address."),
+  );
+  $form['settings']['subject'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Subject'),
+    '#default_value' => $settings['subject'],
+    '#description' => t("The mail's subject."),
+  );
+  $form['settings']['message_html'] = array(
+    '#type' => 'textarea',
+    '#title' => t('HTML message'),
+    '#default_value' => $settings['message_html'],
+    '#description' => t("The message body in HTML format."),
+  );
+  $form['settings']['message_plaintext'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Text message'),
+    '#default_value' => $settings['message_plaintext'],
+    '#description' => t("Optional plaintext portion of a multipart e-mail."),
+  );
+  $form['settings']['attachments'] = array(
+    '#type' => 'textarea',
+    '#title' => t('Attachments'),
+    '#default_value' => $settings['attachments'],
+    '#description' => t('A list of attachments, one file per line. The format of each line is "[mimetype]:[path]", e.g. "image/png:files/images/mypic.png"'),
+  );
+}
+
+/**
+ * Action "Send an HTML mail to an arbitrary mail address" configuration form
+ */
+function mimemail_rules_action_mail_form($settings = array(), &$form) {
+  $form['settings']['to'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Recipient'),
+    '#default_value' => isset($settings['to']) ? $settings['to'] : '',
+    '#description' => t("The mail's recipient address. You may separate multiple addresses with comma."),
+    '#required' => TRUE,
+    '#weight' => -1,
+  );
+  $form['settings']['cc'] = array(
+    '#type' => 'textfield',
+    '#title' => t('CC Recipient'),
+    '#default_value' => isset($settings['cc']) ? $settings['cc'] : '',
+    '#description' => t("The mail's carbon copy address. You may separate multiple addresses with comma."),
+    '#required' => FALSE,
+    '#weight' => 0,
+  );
+  $form['settings']['bc'] = array(
+    '#type' => 'textfield',
+    '#title' => t('BCC Recipient'),
+    '#default_value' => isset($settings['bc']) ? $settings['bc'] : '',
+    '#description' => t("The mail's blind carbon copy address. You may separate multiple addresses with comma."),
+    '#required' => FALSE,
+    '#weight' => 0,
+  );
+  mimemail_rules_action_mail_to_user_form($settings, $form);
+}
+
+/**
+ * Action "Send an HTML mail to users of a role" configuration form
+ */
+function mimemail_rules_action_mail_to_users_of_role_form($settings = array(), &$form) {
+  // Select only non-anonymous user roles because anonymous users won't have emails.
+  $roles = array_map('filter_xss_admin', user_roles(TRUE));
+
+  $form['settings']['recipients'] = array(
+    '#type' => 'checkboxes',
+    '#title' => t('Recipient roles'),
+    '#prefix' => t('WARNING: This may cause problems if there are too many users of these roles on your site, as your server may not be able to handle all the mail requests all at once.'),
+    '#required' => TRUE,
+    '#default_value' => isset($settings['recipients']) ? $settings['recipients'] : array(),
+    '#options' => $roles,
+    '#description' => t('Select the roles whose users should receive this email.'),
+  );
+  
+  mimemail_rules_action_mail_to_user_form($settings, $form);
+}
Index: theme/mimemail-message.tpl.php
===================================================================
RCS file: theme/mimemail-message.tpl.php
diff -N theme/mimemail-message.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ theme/mimemail-message.tpl.php	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,40 @@
+<?php
+
+// $Id$
+
+/**
+ * @file
+ * Default theme implementation to format an HTML mail.
+ *
+ * Copy this file in your default theme folder to create a custom themed mail.
+ * Rename it to mimemail-message--<mailkey>.tpl.php to override it for a
+ * specific mail.
+ *
+ * Available variables:
+ * - $subject: message subject
+ * - $body: message body
+ * - $css: inline style sheets
+ * - $mailkey: message identifier
+ *
+ * @see template_preprocess_mimemail_message()
+ */
+?>
+<html>
+  <head>
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+    <?php if ($css): ?>
+    <style type="text/css">
+      <!--
+      <?php print $css ?>
+      -->
+    </style>
+    <?php endif; ?>
+  </head>
+  <body id="mimemail-body"<?php if ($mailkey) : print ' class="mailkey-'. $mailkey .'"'; endif; ?>>
+    <div id="center">
+      <div id="main">
+        <?php print $body ?>
+      </div>
+    </div>
+  </body>
+</html>
