Index: mimemail.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/mimemail/mimemail.module,v retrieving revision 1.31.2.3 diff -u -p -r1.31.2.3 mimemail.module --- mimemail.module 14 Apr 2009 23:08:59 -0000 1.31.2.3 +++ mimemail.module 14 Aug 2009 10:39:33 -0000 @@ -303,22 +303,24 @@ function mimemail_theme() { function template_preprocess_mimemail_message(&$variables) { $theme = variable_get('theme_default', NULL); + $styles = drupal_get_path('theme', $theme) .'/mail.css'; + // 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'; - } + if (file_exists($styles)) { + $css = ''; + } else { + // If no mail.css was found, convert the output of drupal_get_css() + // from linked stylesheets to embedded stylesheets. + $patterns = array('@@e"); - // If no mail.css was found, gather all style sheets - if (!file_exists($styles)) { - // embed a version of all style definitions - $styles = preg_replace('|\n"'); - // Process each style sheet - foreach (explode("\n", $styles) as $style) { - if (file_exists($style)) $css .= file_get_contents($style); + $css = preg_replace($patterns, $replaces, drupal_get_css()); } - - $variables['css'] = str_replace(' ','', str_replace("\n", '', $css)); + // Break up long lines and collapse repeated whitespace + $variables['css'] = preg_replace(array('/([{};])/','/( )\1+/'),array("\$1\n",'$1'),$css); }