diff --git a/messaging.info b/messaging.info
index f43d9d2..9110a57 100644
--- a/messaging.info
+++ b/messaging.info
@@ -1,6 +1,7 @@
 name = Messaging
 description = Messaging system. This is the base module for the Messaging Framework
 package = Messaging
+dependencies[] = mimemail
 version = VERSION
 core = 7.x
 files[] = messaging.message.inc
diff --git a/messaging_htmlmail/messaging_htmlmail.inc b/messaging_htmlmail/messaging_htmlmail.inc
index 03fe0a6..c9691bf 100644
--- a/messaging_htmlmail/messaging_htmlmail.inc
+++ b/messaging_htmlmail/messaging_htmlmail.inc
@@ -409,223 +409,3 @@ class Messaging_HTML_MailSystem extends DefaultMailSystem {
     return trim($header);
   }
 }
-/**
- * Common mail functions for sending e-mail, taken from Drupal's mime-mail module
- * 
- *   Allie Micka < allie at pajunas dot com >
- *   Originally written by Gerhard.
- */
-
-/**
- * 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
- *
- * @return an absolute :
- */
-function _mimemail_file($url = NULL, $name = '', $type = '', $disposition = 'related') {
-  static $files = array();
-  static $filenames = array();
-
-  if ($url) {
-    $url = _mimemail_url($url, 'TRUE');
-
-    // If the $url is absolute, we're done here.
-    if (strpos($url, '://') !== FALSE || preg_match('!mailto:!', $url)) {
-      return $url;
-    }
-    // The $url is a relative file path, continue processing.
-    else {
-      // Download method is private, and the $url needs conversion.
-      if (variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC) == 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 (isset($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 = 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;
-  }
-  // The $file is not exist, return the $url if possible.
-  elseif ($url) {
-    return $url;
-  }
-
-  $ret = $files;
-  $files = array();
-  $filenames = array();
-  return $ret;
-}
-
-/**
- * Callback for preg_replace_callback()
- */
-function _mimemail_expand_links($matches) {
-  return $matches[1] . _mimemail_url($matches[2]);
-}
-
-/*
- * Split a multi-part message using mime boundaries
- */
-function mimemail_parse_boundary($part) {
-  $m = array();
-  if (preg_match('/.*boundary="?([^";]+)"?.*/', $part['headers']['Content-Type'], $m)) {
-    $boundary = "\n--". $m[1];
-    $body     = str_replace("$boundary--", '', $part['body']);
-    return array_slice(explode($boundary, $body), 1);
-  }
-  return array($part['body']);
-}
-
-/*
- * Split a message (or message part) into its headers and body section
- */
-function mimemail_parse_headers($message) {
-  // Split out body and headers
-  if (preg_match("/^(.*?)\r?\n\r?\n(.*)/s", $message, $match)) {
-    list($hdr, $body) = array($match[1], $match[2]);
-  }
-
-  // Un-fold the headers.
-  $hdr = preg_replace(array("/\r/", "/\n(\t| )+/"), array('', ' '), $hdr);
-
-  $headers = array();
-  foreach (explode("\n", trim($hdr)) as $row) {
-    $split = strpos( $row, ':' );
-    $name = trim(substr($row, 0, $split));
-    $val  = trim(substr($row, $split+1));
-    $headers[$name] = $val;
-  }
-
-  $type = (preg_replace('/\s*([^;]+).*/', '\1', $headers['Content-Type']));
-
-  return array('headers' => $headers, 'body' => $body, 'content-type' => $type);
-}
-
-/*
- * Return a decoded mime part in UTF8
- */
-function mimemail_parse_content($part) {
-  $content = $part['body'];
-
-  // Decode this part
-  if ($encoding = strtolower($part['headers']['Content-Transfer-Encoding'])) {
-    switch ($encoding) {
-
-      case 'base64':
-        $content = base64_decode($content);
-        break;
-
-      case 'quoted-printable':
-        $content = quoted_printable_decode($content);
-        break;
-
-      case '7bit':  // 7bit is the RFC default
-        break;
-    }
-  }
-
-  // Try to convert character set to UTF-8.
-  if (preg_match('/.*charset="?([^";]+)"?.*/', $part['headers']['Content-Type'], $m)) {
-    $content = drupal_convert_to_utf8($content, $m[1]);
-    //$content = iconv($m[1], 'utf-8', $content);
-  }
-
-  return $content;
-}
-
-/*
- * Convert a mime part into a file array
- */
-function mimemail_parse_attachment($part) {
-  $m = array();
-  if (preg_match('/.*filename="?([^";])"?.*/', $part['headers']['Content-Disposition'], $m)) {
-    $name = $m[1];
-  }
-  elseif (preg_match('/.*name="?([^";])"?.*/', $part['headers']['Content-Type'], $m)) {
-    $name = $m[1];
-  }
-
-  return array(
-    'filename' => $name,
-    'filemime' => $part['content-type'],
-    'content'  => mimemail_parse_content($part),
-  );
-}
-
-/**
- * Helper function to format urls
- *
- * @param $url an url
- *
- * @return an absolute url, sans mailto:
- */
-function _mimemail_url($url, $embed_file = NULL) {
-  global $base_url;
-  $url = urldecode($url);
-
-  // If the URL is absolute or a mailto, return it as-is.
-  if (strpos($url, '://') !== FALSE || preg_match('!mailto:!', $url)) {
-    $url = str_replace(' ', '%20', $url);
-    return $url;
-  }
-
-  $url = preg_replace( '!^'. base_path() .'!', '', $url, 1);
-
-  // If we're processing to embed the file, we're done here so return.
-  if ($embed_file) return $url;
-
-  if (!preg_match('!^\?q=*!', $url)) {
-    $strip_clean = TRUE;
-  }
-
-  $url = str_replace('?q=', '', $url);
-  list($url, $fragment) = explode('#', $url, 2);
-  list($path, $query) = explode('?', $url, 2);
-
-  // If we're dealing with an intra-document reference, return it.
-  if (empty($path) && !empty($fragment)) {
-    return '#'. $fragment;
-  }
-
-  // If we have not yet returned, then let's clean things up and leave.
-  $url = url($path, array('query' => $query, 'fragment' => $fragment, 'absolute' => TRUE));
-
-
-  // If url() added a ?q= where there should not be one, remove it.
-  if ($strip_clean) $url = preg_replace('!\?q=!', '', $url);
-
-  $url = str_replace('+', '%20', $url);
-  return $url;
-}
-
