diff --git README.txt README.txt
index 0ed08b4..bfc5f86 100644
--- README.txt
+++ README.txt
@@ -20,7 +20,14 @@ To submit bug reports and feature suggestions, or to track changes:
 Installation
 ------------
 
-Install as usual, see http://drupal.org/node/70151 for further information.
+To include inline styles so that your site theme is applied to your html emails,
+download Emogrifier from http://www.pelagodesign.com/sidecar/emogrifier/
+and move the emogrifier.php file to:
+  DRUPAL_ROOT/sites/all/libraries/emogrifier/emogrifier.php
+If available, the libraries module will be used to locate the emogrifier.php
+file.  See http://drupal.org/project/libraries for further information.
+
+Install as usual; see http://drupal.org/node/895232 for further information.
 
 
 Theming
@@ -35,9 +42,9 @@ folder to your current theme's folder.
 admin-> settings -> performance
 [Clear Cached Data]
 
-Template suggestions per module allow seperate templates which effect the emails coming from the
+Template suggestions per module allow separate templates which affect the emails coming from the
 particular module. For user module:
-eg. htmlmail-user.tpl.php
+(e.g.) htmlmail-user.tpl.php
 
 Creating the above file will override email theming template for email coming from the user module.
 You may place the template in your theme's directory but remember that a copy of
@@ -53,9 +60,9 @@ For tips and resources on building HTML e-mails see:
 Important
 ---------
 
-Remember that many email clients will not be happy with certain code, your 
-CSS may conflict with a web-mail providers CSS and HTML in email may expose 
-security hazards. Beyond this, if your still really, really must have HTML in 
+Remember that many email clients will not be happy with certain code.  Your 
+CSS may conflict with a web-mail provider's CSS, and HTML in email may expose 
+security hazards. Beyond this, if you still really, really must have HTML in 
 your email, you may find this module useful.
 
 
diff --git emogrifier/emogrifier.inc emogrifier/emogrifier.inc
new file mode 100644
index 0000000..9269e51
--- /dev/null
+++ emogrifier/emogrifier.inc
@@ -0,0 +1,92 @@
+<?php
+/**
+ * If the Emogrifier <http://www.pelagodesign.com/sidecar/emogrifier/> exists,
+ * the CSS styles inside the the $message['body'] are inserted into the other
+ * HTML tags within the same $message['body'] as inline style attributes, 
+ * based on CSS selectors.
+ *
+ * This function is based on code in the simplenews_template module.
+ *
+ * This emogrifier differs from that of simplenews_template in that it permits
+ * modules or users to adjoin CSS into the $message['body'] using the HTML 
+ * <style> tag.  The function searches the entire body for style tags, 
+ * concatenates them in order of appearance in the file, then sends them to
+ * the Emogrifier script. 
+ *
+ * Note that the method modifies the $message['body'] directly, and the 
+ * return value is the modified $message['body'] string as well. 
+ *
+ * @param $message
+ *           The message array to be sent. This function works directly 
+ *           on the $message['body'].
+ * @return $message['body']
+ *           The modified message body string with inlined CSS applied.
+ */
+function _htmlmail_emogrify(&$message) {
+  if ($emogrifier = &_htmlmail_emogrifier()) {
+    $style = array();
+    // Pull out the contents of any style tags
+    if (preg_match_all("@<style[^>]*>(.*)</style>@Usi", $message['body'], $matches, PREG_PATTERN_ORDER)) {
+      $style = $matches[1];
+      // Remove the (now redundant) rules to reduce overall filesize.
+      $message['body'] = str_replace($matches[0],'',$message['body']);
+    }
+    // Emogrify can't handle several CSS rules on one line. As a precaution,
+    // we therefore insert LF after each closing bracket.
+    $style = preg_replace('/}\s*/', "}\n", implode("\n", $style));
+    // Get and reset error levels so we dont get DOMDocument::loadHTML() errors.
+    $errorlevel = error_reporting(0);
+    // Inline the CSS rules.
+    $emogrifier->setHTML($message['body']);
+    $emogrifier->setCSS($style);
+    $message['body'] = $emogrifier->emogrify();
+    error_reporting($errorlevel);
+  }
+  return $message['body'];
+}
+
+/**
+ * Returns an instance of the Emogrifier class, if available.
+ * If needed, loads the appropriate class file.
+ *
+ * @param &$paths = array()
+ *   Additional paths relative to DRUPAL_ROOT to search for the emogrifier.php
+ *   library. A default set of search paths will be added.
+ *
+ * @return
+ *   An instance of the Emogrifier class if available, else FALSE.
+ */
+function &_htmlmail_emogrifier(&$paths = array()) {
+  $emogrifier = FALSE;
+  if (!is_array($paths)) {
+    if (!empty($paths)) {
+      $paths = array($paths);
+    }
+    else {
+      $paths = array();
+    }
+  }
+  if (class_exists('Emogrifier')) {
+    $emogrifier = new Emogrifier();
+  }
+  elseif (extension_loaded('dom')) {
+    $search = array_flip($paths);
+    $search['sites/all/libraries/emogrifier'] = -1;
+    $search[drupal_get_path('module','htmlmail') . '/emogrifier'] = -2;
+    if (function_exists('libraries_get_path')) {
+      $search[libraries_get_path('emogrifier')] = -3;
+    }
+    $paths = array_flip($search);
+    ksort($paths);
+    foreach ($paths as $dir) {
+      if (is_file("$dir/emogrifier.php")) {
+        include_once "$dir/emogrifier.php";
+        if (class_exists('Emogrifier')) {
+          $emogrifier = new Emogrifier();
+          break;
+        }
+      }
+    }
+  }
+  return $emogrifier;
+}
diff --git htmlmail.admin.inc htmlmail.admin.inc
index 9632a31..e9deb15 100644
--- htmlmail.admin.inc
+++ htmlmail.admin.inc
@@ -18,12 +18,27 @@ function htmlmail_admin_settings() {
     '#default_value' => variable_get('htmlmail_urlfilter', '1'),
     '#description' => t('Turns web and e-mail addresses into clickable links. URLs longer than 72 characters will be truncated.'),
   );
+  $form['htmlmail_sitecss'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Use site CSS'),
+    '#default_value' => variable_get('htmlmail_sitecss', '0'),
+    '#description' => t('Add default theme stylesheets so that content sent by email is styled the same way as content on the website.'),
+  );
+  $disabled = module_load_include('inc','htmlmail','emogrifier/emogrifier') && (_htmlmail_emogrifier() === FALSE);
   $form['htmlmail_emogrifier'] = array(
     '#type' => 'checkbox',
     '#title' => t('Emogrifier'),
-    '#default_value' => variable_get('htmlmail_emogrifier', '0'),
-    '#description' => t('Insert your CSS definitions as inline styles into HTML tags for Outlook 2007 and Google Gmail.<br /><em>Checkbox will be disabled if DOM extension is not loaded.</em>'),
-    '#disabled' => !extension_loaded('dom'),
+    '#default_value' => $disabled ? 0 : variable_get('htmlmail_emogrifier', '0'),
+    '#description' => t('Insert your CSS definitions as inline styles into HTML tags for Outlook 2007 and Google Gmail.<br /><em>Checkbox will be disabled if the !e library is not available.</em>', array('!e' => 'emogrifier.php')),
+    '#disabled' => $disabled,
+  );
+  $disabled = !module_exists('transliteration');
+  $form['htmlmail_transliteration'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Transliteration'),
+    '#default_value' => $disabled ? 0 : variable_get('htmlmail_transliteration', '0'),
+    '#description' => t('Convert non-latin text to US-ASCII equivalents.<br /><em>Checkbox will be disabled if the !t module is not enabled.</em>', array('!t' => 'transliteration')),
+    '#disabled' => $disabled,
   );
   $form['htmlmail_debug'] = array(
     '#type' => 'checkbox',
diff --git htmlmail.install htmlmail.install
index 6380ce9..c9749ef 100644
--- htmlmail.install
+++ htmlmail.install
@@ -23,3 +23,54 @@ function htmlmail_uninstall() {
   variable_set('mail_system', array('default-system' => 'DefaultMailSystem'));
   cache_clear_all('variables', 'cache');
 }
+
+/**
+ * Implementation of hook_requirements().
+ */
+function htmlmail_requirements($phase) {
+  $requirements = array();
+  if ($phase == 'runtime') {
+    $t = get_t();
+    $libraries = module_exists('libraries');
+    $requirements['libraries'] = array(
+      'title' => 'Libraries module',
+      'value' => $libraries ? 'Enabled' : 'Disabled',
+      'severity' => $libraries ? REQUIREMENT_OK : REQUIREMENT_WARNING,
+    );
+    $dom = extension_loaded('dom');
+    $requirements['dom'] = array(
+       'title' => 'DOM extension',
+       'value' => $dom ? 'Enabled' : 'Disabled',
+       'description' => $t('The %d extension must be loaded before %e can be used with the %m module.',
+                           array('%d' => 'dom',
+                                 '%e' => 'emogrifier',
+                                 '%m' => 'htmlmail')),
+       'severity' => $dom ? REQUIREMENT_OK : REQUIREMENT_WARNING,
+    );
+    $transliteration = function_exists('transliteration_get');
+    $requirements['transliteration'] = array(
+       'title' => 'Transliteration module',
+       'value' => $transliteration ? 'Enabled' : 'Disabled',
+       'description' => $t('The %m module optionally uses the %t module to ensure consistent display on mobile devices.',
+                           array('%m' => 'htmlmail',
+                                 '%t' => 'transliteration')),
+       'severity' => $transliteration ? REQUIREMENT_OK : REQUIREMENT_WARNING,
+    );
+    if (module_load_include('inc','htmlmail','emogrifier/emogrifier')) {
+      $paths = array();
+      $emogrifier = _htmlmail_emogrifier($paths) !== FALSE;
+      $requirements['emogrifier'] = array(
+        'title' => 'Emogrifier class',
+        'value' =>  $emogrifier ? 'Available' : 'Unavailable',
+        'description' => $t("The %m module optionally uses the %l library to convert CSS to inline styles for more consistent display on webmail and mobile devices.  The following directories were searched: !p",
+                            array('%m' => 'htmlmail',
+                                  '%l' => 'emogrifier.php',
+                                  '!p' => '<ul><li>' . implode('</li><li>',$paths) . '</li></ul>',
+                                )
+                            ),
+        'severity' => $emogrifier ? REQUIREMENT_OK : REQUIREMENT_WARNING,
+      );
+    }
+  }
+  return $requirements;
+}
diff --git htmlmail.mail.inc htmlmail.mail.inc
index 61675e3..d7427ff 100644
--- htmlmail.mail.inc
+++ htmlmail.mail.inc
@@ -40,6 +40,12 @@ class HTMLMailMailSystem implements MailSystemInterface {
       $mimeheaders[] = $name . ': ' . mime_header_encode($value);
     }
     $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
+    $extra = '';
+    if (isset($message['headers']['Return-Path']) &&
+	!ini_get('safe_mode') &&
+	!strpos(ini_get('sendmail_path'), ' -f')) {
+      $extra = '-f ' . $message['headers']['Return-Path'];
+    }
     return mail(
       $message['to'],
       mime_header_encode($message['subject']),
@@ -50,7 +56,8 @@ class HTMLMailMailSystem implements MailSystemInterface {
       preg_replace('@\r?\n@', $line_endings, $message['body']),
       // For headers, PHP's API suggests that we use CRLF normally,
       // but some MTAs incorrectly replace LF with CRLF. See #234403.
-      join("\n", $mimeheaders)
+      join("\n", $mimeheaders),
+      $extra
     );
   }
 }
diff --git htmlmail.module htmlmail.module
index ce7eb4a..fe931e7 100644
--- htmlmail.module
+++ htmlmail.module
@@ -96,10 +96,17 @@ function htmlmail_mail_alter(&$message) {
     $message['body'] = theme('htmlmail', $message);
 
     // Emogrify
-    if (variable_get('htmlmail_emogrifier', '0')) {
+    if (variable_get('htmlmail_emogrifier', '0') &&
+        module_load_include('inc','htmlmail','emogrifier/emogrifier')) {
       $message['body'] = _htmlmail_emogrify($message);
     }
 
+    // Use transliteration to ensure consistent display on mobile devices.
+    if (variable_get('htmlmail_transliteration', '0') &&
+	function_exists('transliteration_get')) {
+	$message['body'] = transliteration_get($message['body']);
+    }
+
     // Send the module name in email for theme template suggestions
     if (variable_get('htmlmail_debug', '0')) {
       $message['body'] .= '<p>Debug: module = ' . $message['module'] . '</p>';
@@ -121,6 +128,44 @@ function htmlmail_theme() {
 }
 
 /**
+ * This function works like drupal_get_css() except that it returns css file
+ * contents rather than links, for compatibility with emogrifier.
+ */
+
+function _htmlmail_get_css() {
+  $output = '';
+  // @todo Perhaps is is possible to use a callback function together with
+  // hook_element_info() or hook_element_info_alter() to make drupal_render()
+  // work for us and avoid the following cut-and-paste from drupal_get_css().
+  $css = drupal_add_css();
+  drupal_alter('css',$css);
+  uasort($css, 'drupal_sort_css_js');
+  $previous_item = array();
+  foreach ($css as $key => $item) {
+    if ($item['type'] == 'file') {
+      $basename = isset($item['basename']) ? $item['basename'] : basename($item['data']);
+      if (isset($previous_item[$basename])) {
+        unset($css[$previous_item[$basename]]);
+      }
+      $previous_item[$basename] = $key;
+    }
+  }
+  // End of cut-and-paste from drupal_get_css() code.
+  foreach($css as $item) {
+    switch ($item['type']) {
+      case 'file':
+	$output .= file_get_contents(DRUPAL_ROOT . base_path() . $item['data']);
+        break;
+      case 'inline':
+	$output .= $item['data'];
+        break;
+      default:
+    }
+  }
+  return $output;
+}
+
+/**
  * Process variables to format e-mail.
  *
  * @see htmlmail.tpl.php
@@ -129,7 +174,13 @@ function template_preprocess_htmlmail(&$variables) {
   $variables['path'] = url($variables['directory'], array('absolute' => TRUE));
   $variables['header'] = variable_get('htmlmail_header', '');
   $variables['footer'] = variable_get('htmlmail_footer', '');
-  $variables['css'] = variable_get('htmlmail_css', '');
+  $variables['css'] = '';
+  // Start with standard theme css.
+  if (variable_get('htmlmail_sitecss', '0')) {
+    $variables['css'] .= _htmlmail_get_css();
+  }
+  // Custom rules override site defaults.
+  $variables['css'] .= variable_get('htmlmail_css', '');
   $variables['template_files'][] = 'htmlmail-' . $variables['module'];
 }
 
@@ -144,50 +195,3 @@ function htmlmail_mail($key, &$message, $params) {
     break;
   }
 }
-
-/**
- * If the Emogrifier <http://www.pelagodesign.com/sidecar/emogrifier/> exists,
- * the CSS styles inside the the $message['body'] are inserted into the other
- * HTML tags within the same $message['body'] as inline style attributes, 
- * based on CSS selectors.
- *
- * This function is based on code in the simplenews_template module.
- *
- * This emogrifier differs from that of simplenews_template in that it permits
- * modules or users to adjoin CSS into the $message['body'] using the HTML 
- * <style> tag.  The function searches the entire body for style tags, 
- * concatenates them in order of appearance in the file, then sends them to
- * the Emogrifier script. 
- *
- * Note that the method modifies the $message['body'] directly, and the 
- * return value is the modified $message['body'] string as well. 
- *
- * @param $message
- *           The message array to be sent. This function works directly 
- *           on the $message['body'].
- * @return $message['body']
- *           The modified message body string with inlined CSS applied.
- */
-function _htmlmail_emogrify(&$message) {
-  $path = drupal_get_path('module', 'htmlmail') . '/emogrifier/emogrifier.php';
-  if (is_file($path)) {
-    $style = array();
-    // Pull out the contents of any style tags
-    if (preg_match_all("@<style[^>]*>(.*)</style>@Usi", $message['body'], $matches, PREG_PATTERN_ORDER)) {
-      $style = $matches[1];
-    }
-    // Emogrify can't handle several CSS rules on one line. As a precaution,
-    // we therefore insert LF after each closing bracket.
-    $style = preg_replace('/}\s*/', "}\n", implode("\n", $style));
-
-    // Inline the CSS rules.
-    include_once $path;
-    // get and reset error levels so we dont get DOMDocument::loadHTML() errors
-    $errorlevel = error_reporting();
-    error_reporting(0);
-    $emogrifier = new Emogrifier($message['body'], $style);
-    $message['body'] = $emogrifier->emogrify();
-    error_reporting($errorlevel);
-  }
-  return $message['body'];
-}
diff --git htmlmail.tpl.php htmlmail.tpl.php
index e35c9ec..044c502 100644
--- htmlmail.tpl.php
+++ htmlmail.tpl.php
@@ -33,7 +33,9 @@
 <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>
