Community Documentation

Theming HTML Mail sent through Mime Mail

Last updated May 27, 2011. Created by sgabe on October 31, 2010.
Edited by NonProfit. Log in to edit this page.

The email messages are formatted using the mimemail-message.tpl.php template file. This includes a CSS style sheet and uses an HTML version of the text.

The included CSS is either:

  • the mail.css file found in your default theme or
  • the combined CSS style sheets of your default theme

To create a custom mail template copy the mimemail-message.tpl.php file from the mimemail/theme directory into your default theme's folder. Both general and by-mailkey theming can be performed:

  • mimemail-message.tpl.php (for all messages)
  • mimemail-message--[mailkey].tpl.php (for messages with a specific mailkey)

If you use sub-themes or multiple themes, especially if you use a different administration theme than your default theme, you might end up with a different theme to what you expect. This is a well-known bug which is hard to fix and not just Mime Mail is affected by it but Simplenews too. See #374222: Template files do not work when using admin theme for more information.

In the meantime to cover all cases, you should place the same template files into all theme folders.

How to design safe HTML email

Since some email clients (namely Outlook 2007 and GMail) is tend to only regard inline CSS, you can use the Mime Mail CSS Compressor (based on Emogrifier) to convert CSS styles into inline style attributes. It transmogrifies the HTML source by parsing the CSS and inserting the CSS definitions into tags within the HTML based on the CSS selectors. To use the Compressor, enable the included "Mime Mail CSS Compressor" module.

Some useful tips:

  • Use nested tables for layout.
  • Use inline CSS and avoid shorthand.
  • Use alt text and always include the dimensions of your image.
  • Don’t use floats.
  • Test and retest your email designs on a regular basis with different email clients.

For more detailed information on the subject see:

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Designers/themers, Programmers

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here