When you send a Simplenews newsletter via HTML Mail, here is what happens:

Needs an explanation, some steps.

1-Simplenews configuration

2-HTML Mail configuration

This is the code sequence:

  1. simplenews_send_node() associates the newsletter node id with a list of recipient subscriber ids, and adds them to the simplenews_mail_spool table.
  2. simplenews_mail_spool() retrieves the list, switches to the anonymous user, and initiates sending of each newsletter/recipient combination.
  3. simplenews_mail_mail() loads the node object, adds newsletter context, and calls drupal_mail() to send the message.
  4. After adding some default headers, drupal_mail() calls simplenews_mail() to apply module-specific formatting.
  5. simplenews_mail() calls simplenews_build_node_mail()
  6. If the Translation module is enabled, translation_node_get_translations() attempts to fetch a node in the recipient's preferred language. Otherwise, node_load() is used.
  7. _simplenews_headers() adds Simplenews-specific headers to the message.
  8. node_view($node, 'email_plain') converts the node object to a FAPI render array.
  9. The simplenews_field theme key is applied to each field in the render array.
  10. theme('simplenews_newsletter_body', ...) converts the render array to HTML message body text.
  11. theme('simplenews_newsletter_footer', ...) converts the same render array to HTML message footer text.
  12. If plaintext output is selected, simplenews_html_to_text() converts the message body from HTML to plaintext.
  13. drupal_mail() calls HTMLMailSystem::format() to format the message.
  14. If the Mail MIME module is enabled, HTMLMailSystem::formatMailMIME() uses the MailMIME class functions to parse the message body into MIME parts, convert referenced images into inline attachments, and extract the text/html message part.
  15. theme('htmlmail', $message) applies the htmlmail--simplenews.tpl.php template to add custom theming.
  16. mailsystem_html_to_text creates a plaintext alternative to the templated output.
  17. If the Echo module is enabled, the echo_themed_page() passes the message body, title, and theme as POST arguments to drupal_http_request(), which loads the url('echo') page to wrap the themed, templated message body in a mail-specific themed page.
  18. If a post-filter is selected, check_markup() applies it to the themed, templated, wrapped message body. This is where the the Emogrifier module may be used to convert CSS stylesheets to inline style attributes.
  19. drupal_mail() passes the themed, templated, wrapped, and converted message to HTMLMailSystem::mail(), which passes the message recipient, subject, body, and headers to the PHP mail() function to send the message.