diff --git a/includes/phpmailer.drupal.inc b/includes/phpmailer.drupal.inc
index 0b91d5b..933c535 100644
--- a/includes/phpmailer.drupal.inc
+++ b/includes/phpmailer.drupal.inc
@@ -6,121 +6,155 @@
  */
 
 /**
- * Send out an e-mail.
- *
- * @param $message
- *   Message array structure.
+ * Use phpmailer module to send emails from drupal mail system.
  */
-function phpmailer_send($message) {
-  static $mail;
+class PHPMailerMailSystem implements MailSystemInterface {
 
-  if (!isset($mail)) {
-    if (!phpmailer_load_library()) {
-      return FALSE;
-    }
-    $mail = new DrupalPHPMailer();
+  private static $mail;
+
+  /**
+   * Concatenate and wrap the e-mail body for either
+   * plain-text or HTML emails.
+   *
+   * @param $message
+   *   A message array, as described in hook_mail_alter().
+   *
+   * @return
+   *   The formatted $message.
+   */
+  public function format(array $message) {
+    // Join the body array into one string.
+    $message['body'] = implode("\n\n", $message['body']);
+
+    // Convert any HTML to plain-text.
+    $message['body'] = drupal_html_to_text($message['body']);
+
+    // Wrap the mail body for sending.
+    $message['body'] = drupal_wrap_mail($message['body']);
+
+    return $message;
   }
 
-  try {
-    // Parse 'From' e-mail address.
-    $from = phpmailer_parse_address($message['from']);
-    $from = reset($from);
-    $mail->From = $from['mail'];
-    if ($from['name'] != '') {
-      $mail->FromName = $from['name'];
+  /**
+   * Send the e-mail message.
+   *
+   * @see drupal_mail()
+   *
+   * @param $message
+   *   A message array, as described in hook_mail_alter().
+   * @return
+   *   TRUE if the mail was successfully accepted, otherwise FALSE.
+   */
+  public function mail(array $message) {
+
+    if (!isset(self::$mail)) {
+      if (!phpmailer_load_library()) {
+        return FALSE;
+      }
+      self::$mail = new DrupalPHPMailer();
     }
-    unset($message['headers']['From']);
 
-    if (variable_get('phpmailer_debug_email', '') === '') {
-      // Set recipients.
-      foreach (phpmailer_parse_address($message['to']) as $address) {
-        $mail->AddAddress($address['mail'], $address['name']);
+    try {
+      // Parse 'From' e-mail address.
+      $parsed_from = phpmailer_parse_address($message['from']);
+      $from = reset($parsed_from);
+      self::$mail->From = $from['mail'];
+      if ($from['name'] != '') {
+        self::$mail->FromName = $from['name'];
       }
-      // Extract CCs and BCCs from headers.
-      if (isset($message['headers']['CC'])) {
-        foreach (phpmailer_parse_address($message['headers']['CC']) as $address) {
-          $mail->AddCC($address['mail'], $address['name']);
+      unset($message['headers']['From']);
+
+      if (variable_get('phpmailer_debug_email', '') === '') {
+        // Set recipients.
+        foreach (phpmailer_parse_address($message['to']) as $address) {
+          self::$mail->AddAddress($address['mail'], $address['name']);
         }
-      }
-      if (isset($message['headers']['BCC'])) {
-        foreach (phpmailer_parse_address($message['headers']['BCC']) as $address) {
-          $mail->AddBCC($address['mail'], $address['name']);
+        // Extract CCs and BCCs from headers.
+        if (isset($message['headers']['CC'])) {
+          foreach (phpmailer_parse_address($message['headers']['CC']) as $address) {
+            self::$mail->AddCC($address['mail'], $address['name']);
+          }
+        }
+        if (isset($message['headers']['BCC'])) {
+          foreach (phpmailer_parse_address($message['headers']['BCC']) as $address) {
+            self::$mail->AddBCC($address['mail'], $address['name']);
+          }
         }
       }
-    }
-    else {
-      // Reroute to debug e-mail address.
-      $mail->AddAddress(variable_get('phpmailer_debug_email', ''));
-    }
-    unset($message['headers']['CC'], $message['headers']['BCC']);
-
-    // Extract Reply-To from headers.
-    if (isset($message['headers']['Reply-To'])) {
-      foreach (phpmailer_parse_address($message['headers']['Reply-To']) as $address) {
-        $mail->AddReplyTo($address['mail'], $address['name']);
+      else {
+        // Reroute to debug e-mail address.
+        self::$mail->AddAddress(variable_get('phpmailer_debug_email', ''));
       }
-      unset($message['headers']['Reply-To']);
-    }
-    elseif (variable_get('smtp_always_replyto', FALSE)) {
-      // If no Reply-To header has been explicitly set, use the From address to
-      // be able to respond to e-mails sent via Google Mail.
-      $mail->AddReplyTo($from['mail'], $from['name']);
-    }
+      unset($message['headers']['CC'], $message['headers']['BCC']);
 
-    // Extract Content-Type and charset.
-    if (isset($message['headers']['Content-Type'])) {
-      $content_type = explode(';', $message['headers']['Content-Type']);
-      $mail->ContentType = trim(array_shift($content_type));
-      foreach ($content_type as $param) {
-        $param = explode('=', $param, 2);
-        $key = trim($param[0]);
-        if ($key == 'charset') {
-          $mail->CharSet = trim($param[1]);
+      // Extract Reply-To from headers.
+      if (isset($message['headers']['Reply-To'])) {
+        foreach (phpmailer_parse_address($message['headers']['Reply-To']) as $address) {
+          self::$mail->AddReplyTo($address['mail'], $address['name']);
         }
-        else {
-          $mail->ContentType .= '; ' . $key . '=' . trim($param[1]);
+        unset($message['headers']['Reply-To']);
+      }
+      elseif (variable_get('smtp_always_replyto', FALSE)) {
+        // If no Reply-To header has been explicitly set, use the From address to
+        // be able to respond to e-mails sent via Google Mail.
+        self::$mail->AddReplyTo($from['mail'], $from['name']);
+      }
+
+      // Extract Content-Type and charset.
+      if (isset($message['headers']['Content-Type'])) {
+        $content_type = explode(';', $message['headers']['Content-Type']);
+        self::$mail->ContentType = trim(array_shift($content_type));
+        foreach ($content_type as $param) {
+          $param = explode('=', $param, 2);
+          $key = trim($param[0]);
+          if ($key == 'charset') {
+            self::$mail->CharSet = trim($param[1]);
+          }
+          else {
+            self::$mail->ContentType .= '; ' . $key . '=' . trim($param[1]);
+          }
         }
+        unset($message['headers']['Content-Type']);
       }
-      unset($message['headers']['Content-Type']);
-    }
 
-    // Set additional properties.
-    $properties = array(
-      'X-Priority'                => 'Priority',
-      'Content-Transfer-Encoding' => 'Encoding',
-      'Sender'                    => 'Sender',
-      'Message-ID'                => 'MessageID',
-      // Custom property.
-      // @see DrupalPHPMailer::CreateHeader()
-      'Return-Path'               => 'ReturnPath',
-    );
-    foreach ($properties as $source => $property) {
-      if (isset($message['headers'][$source])) {
-        $mail->$property = $message['headers'][$source];
-        unset($message['headers'][$source]);
+      // Set additional properties.
+      $properties = array(
+        'X-Priority'                => 'Priority',
+        'Content-Transfer-Encoding' => 'Encoding',
+        'Sender'                    => 'Sender',
+        'Message-ID'                => 'MessageID',
+        // Custom property.
+        // @see DrupalPHPMailer::CreateHeader()
+        'Return-Path'               => 'ReturnPath',
+      );
+      foreach ($properties as $source => $property) {
+        if (isset($message['headers'][$source])) {
+          self::$mail->$property = $message['headers'][$source];
+          unset($message['headers'][$source]);
+        }
       }
-    }
 
-    // This one is always set by PHPMailer.
-    unset($message['headers']['MIME-Version']);
+      // This one is always set by PHPMailer.
+      unset($message['headers']['MIME-Version']);
 
-    // Add remaining header lines.
-    // Note: Any header lines MUST already be checked by the caller for unwanted
-    // newline characters to avoid header injection.
-    // @see PHPMailer::SecureHeader()
-    foreach ($message['headers'] as $key => $value) {
-      $mail->AddCustomHeader("$key:$value");
-    }
+      // Add remaining header lines.
+      // Note: Any header lines MUST already be checked by the caller for unwanted
+      // newline characters to avoid header injection.
+      // @see PHPMailer::SecureHeader()
+      foreach ($message['headers'] as $key => $value) {
+        self::$mail->AddCustomHeader("$key:$value");
+      }
 
-    $mail->Subject = $message['subject'];
-    $mail->Body = $message['body'];
+      self::$mail->Subject = $message['subject'];
+      self::$mail->Body = $message['body'];
 
-    return $mail->Send();
-  }
-  catch (phpmailerException $e) {
-    drupal_set_message(t('Sending of at least one e-mail failed. The error returned was:<br />@error.', array('@error' => $e->getMessage())), 'error');
-    watchdog('phpmailer', $e->getMessage(), NULL, WATCHDOG_ERROR);
-    return FALSE;
+      return self::$mail->Send();
+    }
+    catch (phpmailerException $e) {
+      drupal_set_message(t('Sending of at least one e-mail failed. The error returned was:<br />@error.', array('@error' => $e->getMessage())), 'error');
+      watchdog('phpmailer', $e->getMessage(), NULL, WATCHDOG_ERROR);
+      return FALSE;
+    }
   }
 }
 
diff --git a/phpmailer.admin.inc b/phpmailer.admin.inc
index 903330a..d456ab7 100644
--- a/phpmailer.admin.inc
+++ b/phpmailer.admin.inc
@@ -181,13 +181,13 @@ function phpmailer_settings_form_submit($form, &$form_state) {
   // Enable/disable mail sending subsystem.
   if ($form_state['values']['smtp_on']) {
     if (!phpmailer_enabled()) {
-      variable_set('smtp_library', drupal_get_filename('module', 'phpmailer'));
+      variable_set('mail_system', array('default-system' => 'PHPMailerMailSystem'));
       drupal_set_message(t('PHPMailer will be used to deliver all site e-mails.'));
       watchdog('phpmailer', 'PHPMailer has been enabled.');
     }
   }
   else if (phpmailer_enabled()) {
-    variable_del('smtp_library');
+    variable_set('mail_system', array('default-system' => 'DefaultMailSystem'));
     drupal_set_message(t('PHPMailer has been disabled.'));
     watchdog('phpmailer', 'PHPMailer has been disabled.');
   }
diff --git a/phpmailer.info b/phpmailer.info
index 79fd48d..6125ff1 100644
--- a/phpmailer.info
+++ b/phpmailer.info
@@ -1,5 +1,7 @@
 name = PHPMailer
 description = Integrates the PHPMailer library for SMTP e-mail delivery.
-dependencies[] = libraries
+core = 7.x
 package = Mail
-core = 6.x
\ No newline at end of file
+dependencies[] = libraries
+files[] = includes/phpmailer.class.inc
+files[] = includes/phpmailer.drupal.inc
diff --git a/phpmailer.module b/phpmailer.module
index 8ad2f2c..cee8b73 100644
--- a/phpmailer.module
+++ b/phpmailer.module
@@ -60,7 +60,8 @@ function phpmailer_form_mimemail_admin_settings_alter(&$form, &$form_state) {
  * Determine if PHPMailer is used to deliver e-mails.
  */
 function phpmailer_enabled() {
-  return strpos(variable_get('smtp_library', ''), 'phpmailer');
+  $mail_system = variable_get('mail_system', '');
+  return $mail_system['default-system'] == 'PHPMailerMailSystem';
 }
 
 if (phpmailer_enabled() && !function_exists('drupal_mail_wrapper')) {
@@ -183,7 +184,7 @@ function phpmailer_enable() {
  */
 function phpmailer_disable() {
   if (phpmailer_enabled()) {
-    variable_del('smtp_library');
+    variable_set('mail_system', array('default-system' => 'DefaultMailSystem'));
     variable_del('smtp_on');
     drupal_set_message(t('PHPMailer has been disabled.'));
   }
