In this video, we will apply a theme to our newsletters.Back on the HTML Mail project page, we can scroll down and find the configuration steps listed right there for us (you can also find these in the README.txt included with the module download).

We've already configured the Mail System settings, so the next thing we need to do is configure the HTML Mail settings. These are found at "Configuration => System => HTML Mail"

Here we have a three step process laid out for us.

  1. First we need to configure the .tpl.php file. The instructions tell us what our file name options are, and then tells us where it will look for our .tpl.php file.
    • Because we want to affect all emails that are sent by the simplenews module, we're going to use the second variation. So, our file name will be "htmlmail--simplenews.tpl.php"
    • Because we haven't chosen an email theme yet, it will use the file that is in the HTML Mail module directory. "sites/all/modules/htmlmail/htmlmail--simplenews.tpl.php" This file actually comes with the module as an example, so we can just edit it to test it out.
      • I'm going to change the "Click here…" link to the following
        • "<div class="htmlmail-simplenews-link">
              Does this message look funny?
          <a href="<?php echo url('node/' . $params['simplenews_source']->getNode()->nid, array('absolute' => TRUE)); ?>">
              Click here to view it on the web.
      • Now, if we send another test email, we'll see the change is in effect.
      • I'm going to go ahead and undo those changes, and save this file with it's original content.
  2. Step two lets us choose a theme to apply to our newsletters
    • I'll choose the Bartik theme.
  3. Finally, step three lets us choose how the messages should be filtered, after they are themed. We could simply choose one of the default filters, but I like to create a new text format, just for HTML emails.
    1. So we're going to go to "Configuration => Content authoring => Text formats"
    2. Then, we'll click "Add text format"
      • Name: HTML emails
      • Roles: I'm going to uncheck administrator. The system will use it automatically, but we don't want it cluttering the site for human users.
      • Enabled filters: Emogrifier, Transliteration
    3. Now if we go back to our HTML Mail settings, and refresh, we can select "HTML emails" as our post-filter.

Once our settings are configured, we're ready to send another test newsletter.

In the mac "Mail" application, you can clearly see that our theme is in effect. It doesn't look real pretty, and would need some modifications to look just right. However, you can see that it respects the header, left sidebar, content and footer regions.

If we take a look in gmail, you can see that there is even less styling. we've lost the background colors, but it does still respect the various regions.

In the next video, we're going to create a very basic, one-column theme for our simplenews emails.