diff --git a/includes/simplenews.mail.inc b/includes/simplenews.mail.inc
index b16110c..4c0ee82 100644
--- a/includes/simplenews.mail.inc
+++ b/includes/simplenews.mail.inc
@@ -726,4 +726,36 @@ function simplenews_build_unsubscribe_mail(&$message, $params) {
     $body = simplenews_subscription_confirmation_text('unsubscribe_unsubscribed', $langcode);
     $message['body'][] = token_replace($body, $context, array('sanitize' => FALSE));
   }
+}
+
+/**
+ * A mail sending implementation that captures sent messages to a variable.
+ *
+ * This class is for running tests or for development and does not convert HTML
+ * to plaintext.
+ */
+class SimplenewsHTMLTestingMailSystem implements MailSystemInterface {
+
+  /**
+   * Implements MailSystemInterface::format().
+   */
+  public function format(array $message) {
+    // Join the body array into one string.
+    $message['body'] = implode("\n\n", $message['body']);
+    // Wrap the mail body for sending.
+    $message['body'] = drupal_wrap_mail($message['body']);
+    return $message;
+  }
+
+  /**
+   * Implements MailSystemInterface::mail().
+   */
+  public function mail(array $message) {
+    $captured_emails = variable_get('drupal_test_email_collector', array());
+    $captured_emails[] = $message;
+    // @todo: This is rather slow when sending 100 and more mails during tests.
+    // Investigate in other methods like APC shared memory.
+    variable_set('drupal_test_email_collector', $captured_emails);
+    return TRUE;
+  }
 }
\ No newline at end of file
diff --git a/includes/simplenews.source.inc b/includes/simplenews.source.inc
index cfbe148..54862eb 100644
--- a/includes/simplenews.source.inc
+++ b/includes/simplenews.source.inc
@@ -681,7 +681,7 @@ class SimplenewsSourceNode implements SimplenewsSourceNodeInterface {
       return $cache;
     }
 
-    $body = $this->buildBody();
+    $body = $this->buildBody($format);
 
     // Build message body, replace tokens.
     $body = token_replace($body, $this->getTokenContext(), array('sanitize' => FALSE));
@@ -721,6 +721,7 @@ class SimplenewsSourceNode implements SimplenewsSourceNodeInterface {
       'context' => $this->getTokenContext(),
       'key' => $this->getKey(),
       'language' => $this->getLanguage(),
+      'format' => $format,
       )
     );
     $this->cache->set('build', 'footer:' . $format, $footer);
diff --git a/simplenews.module b/simplenews.module
index 250d687..0c3273d 100644
--- a/simplenews.module
+++ b/simplenews.module
@@ -2718,7 +2718,7 @@ function theme_simplenews_field($variables) {
       $output .= '</div>';
 
       // Render the top-level DIV.
-      $output .= '<div class="clearfix">' . $output . '</div>';
+      $output = '<div class="clearfix">' . $output . '</div>';
       break;
   }
   return $output;
@@ -2774,8 +2774,6 @@ function template_preprocess_simplenews_newsletter_footer(&$variables) {
   unset($variables['build']['links']);
   unset($variables['build']['comments']);
 
-  // @todo Replace 'format' by 'view_mode ?
-  $variables['format'] = $variables['category']->format;
   $variables['unsubscribe_text'] = t('Unsubscribe from this newsletter', array(), array('langcode' => $variables['language']));
   $variables['test_message'] = t('This is a test version of the newsletter.', array(), array('langcode' => $variables['language']));
 
diff --git a/tests/simplenews.test b/tests/simplenews.test
index e511f0f..8010878 100644
--- a/tests/simplenews.test
+++ b/tests/simplenews.test
@@ -1796,7 +1796,7 @@ class SimplenewsSourceTestCase extends SimplenewsTestCase {
 
     $edit = array(
       'title' => $this->randomName(),
-      'body[und][0][value]' => "Mail token: [simplenews-subscriber:mail]",
+      'body[und][0][value]' => "Mail token: <strong>[simplenews-subscriber:mail]</strong>",
     );
     $this->drupalPost('node/add/simplenews', $edit, ('Save'));
     $this->assertTrue(preg_match('|node/(\d+)$|', $this->getUrl(), $matches), 'Node created');
@@ -1816,8 +1816,10 @@ class SimplenewsSourceTestCase extends SimplenewsTestCase {
     foreach (array_slice($this->drupalGetMails(), 0, 3) as $mail) {
       // Make sure that the same mail was used in the body token as it has been
       // sent to. Also verify that the mail is plaintext.
-      $this->assertTrue(strpos($mail['body'], $mail['to']) !== FALSE);
+      $this->assertTrue(strpos($mail['body'], '*' . $mail['to'] . '*') !== FALSE);
       $this->assertFalse(strpos($mail['body'], '<strong>'));
+      // Make sure the body is only attached once.
+      $this->assertEqual(1, preg_match_all('/Mail token/', $mail['body'], $matches));
     }
 
     // Report time. @todo: Find a way to actually do some assertions here.
@@ -1825,6 +1827,61 @@ class SimplenewsSourceTestCase extends SimplenewsTestCase {
   }
 
   /**
+   * Send a newsletter with the HTML format.
+   */
+  function testSendHTML() {
+    $this->subscribeUsers(5);
+
+    // Use custom testing mail system to support HTML mails.
+    variable_set('mail_system', array('default-system' => 'SimplenewsHTMLTestingMailSystem'));
+
+    // Set the format to HTML.
+    $this->drupalGet('admin/config/services/simplenews');
+    $this->clickLink(t('edit newsletter category'));
+    $edit = array(
+      'format' => 'html',
+      // @todo: This shouldn't be necessary.
+      'from_address' => $this->randomEmail(),
+    );
+    $this->drupalPost(NULL, $edit, t('Save'));
+
+    $edit = array(
+      'title' => $this->randomName(),
+      'body[und][0][value]' => "Mail token: <strong>[simplenews-subscriber:mail]</strong>",
+    );
+    $this->drupalPost('node/add/simplenews', $edit, ('Save'));
+    $this->assertTrue(preg_match('|node/(\d+)$|', $this->getUrl(), $matches), 'Node created');
+    $node = node_load($matches[1]);
+
+    // Add node to spool.
+    simplenews_add_node_to_spool($node);
+    // Send mails.
+    simplenews_mail_spool();
+
+    // Make sure that 5 mails have been sent.
+    $this->assertEqual(5, count($this->drupalGetMails()));
+
+    // Test that tokens are correctly replaced.
+    foreach (array_slice($this->drupalGetMails(), 0, 3) as $mail) {
+      // Verify title.
+      $this->assertTrue(strpos($mail['body'], '<h2>' . $node->title . '</h2>') !== FALSE);
+
+      // Make sure that the same mail was used in the body token as it has been
+      // sent to.
+      $this->assertTrue(strpos($mail['body'], '<strong>' . $mail['to'] . '</strong>') !== FALSE);
+
+      // Make sure the body is only attached once.
+      $this->assertEqual(1, preg_match_all('/Mail token/', $mail['body'], $matches));
+
+      // Check the plaintext version.
+      $this->assertTrue(strpos($mail['params']['plaintext'], $mail['to']) !== FALSE);
+      $this->assertFalse(strpos($mail['params']['plaintext'], '<strong>'));
+      // Make sure the body is only attached once.
+      $this->assertEqual(1, preg_match_all('/Mail token/', $mail['params']['plaintext'], $matches));
+    }
+}
+
+  /**
    * Test with disabled caching.
    */
   function testSendNoCaching() {
@@ -1857,8 +1914,10 @@ class SimplenewsSourceTestCase extends SimplenewsTestCase {
     foreach (array_slice($this->drupalGetMails(), 0, 3) as $mail) {
       // Make sure that the same mail was used in the body token as it has been
       // sent to. Also verify that the mail is plaintext.
-      $this->assertTrue(strpos($mail['body'], $mail['to']) !== FALSE);
+      $this->assertTrue(strpos($mail['body'], '*' . $mail['to'] . '*') !== FALSE);
       $this->assertFalse(strpos($mail['body'], '<strong>'));
+      // Make sure the body is only attached once.
+      $this->assertEqual(1, preg_match_all('/Mail token/', $mail['body'], $matches));
     }
 
     // Report time. @todo: Find a way to actually do some assertions here.
