You are here

function theme_mimemail_message in Mime Mail 5

Themes the message body.

Parameters

$body: The message body to theme.

$mailkey: An identifier for the message.

Return value

The themed HTML message body.

1 theme call to theme_mimemail_message()
mimemail_prepare in ./mimemail.module
Sends a mime-encoded e-mail.

File

./mimemail.module, line 474
Component module for sending Mime-encoded emails.

Code

function theme_mimemail_message($body, $mailkey = NULL) {
  $output = '<html><head>';
  $output .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />';

  // attempt to include a mail-specific version of the css.
  // if you want smaller mail messages, add a mail.css file to your theme
  $styles = path_to_theme() . '/mail.css';
  $output .= '<style type="text/css"><!--';
  if (!file_exists($styles)) {

    // embed a version of all style definitions
    $styles = preg_replace('|<style.*"' . base_path() . '([^"]*)".*|', '\\1', drupal_get_css());
  }
  foreach (explode("\n", $styles) as $style) {
    if (file_exists($style)) {
      $output .= file_get_contents($style);
    }
  }
  $output .= '--></style></head><body id="mimemail-body"><div id="center"><div id="main">' . $body . '</div></div></body></html>';

  // compress output
  return preg_replace('/\\s+|\\n|\\r|^\\s|\\s$/', ' ', $output);
}