Theming HTML Mail sent through Mime Mail
Last modified: August 6, 2008 - 18:04
The theme function attempts to suck in all of the theme's style-sheets. This "usually" looks OK, but often needs work.
The main issue is usually the fact that your theme's CSS files are designed to render the entire page. So your boiled-down HTML might look like:
<body>
<div id="content">
<?php print $content ?>
</div>
</body>And your CSS might look like this:
body {
background-color: black;
}
#content {
background-color: white;
}However, theme_mimemail_message(), though it uses the same CSS, results in the following HTML:
<body id="mimemail-body">
<?php print $content ?>
</body>Thus, your background color is black (per the body element) but your message content is never rendered as white, because the message layout doesn't include your #content id.
You have 3 options:
- Add
#mimemail-bodyto your CSS with appropriate defaults such as:
#content, #mimemail-body {
background-color: white;
}
- Create a
mail.cssfile. Usually, you can copy your theme'sstyle.cssand begin making appropriate changes. In addition to changing the "offensive" declarations, you can also remove a lot of unused styles (such as sidebars) so that the overall message weight is much lower. - Override
theme_mimemail_message()and do whatever you want. See http://drupal.org/node/55126 for information on how to do this.
