From fbcfd8f8dc88df8fc3fb972551fba308f5728305 Mon Sep 17 00:00:00 2001
From: Bob Vincent <bobvin@pillars.net>
Date: Fri, 11 Mar 2011 05:55:02 -0500
Subject: [PATCH] Provide support for Mail System module.  See http://drupal.org/project/mailsystem

---
 README.txt       |    9 ++++-----
 mimemail.info    |    1 +
 mimemail.install |   17 +++++------------
 3 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/README.txt b/README.txt
index 2725413..e09bd95 100644
--- a/README.txt
+++ b/README.txt
@@ -19,15 +19,14 @@ USAGE
   MimeMailSystem as the responsible mail system for a particular message
   or all mail sent by one module.
 
-  This is done by modifying the $mail_system variable like this: 
+  This can be done through the web by visiting admin/config/system/mailsystem
+  or in a program as follows:
 
-  array(
+  mailsystem_set(array(
     'default-system' => 'DefaultMailSystem',
     '{$module}_{$key}' => 'MimeMailSystem', // Just messages with $key sent by $module.
     '{$module}' => 'MimeMailSystem', // All messages sent by $module.
-  );
-  
-  WARNING! Make sure to not overwrite the variable just append your mail to it!
+  ));
 
   You can use the following optional parameters to build the e-mail:
     'plain':
diff --git a/mimemail.info b/mimemail.info
index 6a2a8ef..ba0924d 100644
--- a/mimemail.info
+++ b/mimemail.info
@@ -1,5 +1,6 @@
 name = Mime Mail
 description = Send MIME-encoded emails with embedded images and attachments.
+dependencies[] = mailsystem
 package = Mail
 core = 7.x
 
diff --git a/mimemail.install b/mimemail.install
index 4e50aca..ae69ce8 100644
--- a/mimemail.install
+++ b/mimemail.install
@@ -6,25 +6,18 @@
  */
 
 /**
- * Implements hook_install().
+ * Implements hook_enable().
  */
-function mimemail_install() {
-  $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
-  $mail_system['mimemail'] = 'MimeMailSystem';
-  variable_set('mail_system', $mail_system);
+function mimemail_enable().
+  mailsystem_set(array('mimemail' => 'MimeMailSystem'));
 }
 
 /**
  * Implements hook_disable().
  */
 function mimemail_disable() {
-  $mail_system = variable_get('mail_system', array('default-system' => 'DefaultMailSystem'));
-  $default_system = $mail_system['default-system'];
-  if ($default_system == 'MimeMailSystem') {
-    $mail_system['default-system'] = 'DefaultMailSystem';
-    variable_set('mail_system', $mail_system);
-    variable_set('mimemail_alter', FALSE);
-  }
+  mailsystem_clear(array('mimemail' => 'MimeMailSystem'));
+  variable_set('mimemail_alter', FALSE);
 }
 
 /**
-- 
1.7.1

