Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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:
simplenews_send_node()
associates the newsletter node id with a list of recipient subscriber ids, and adds them to thesimplenews_mail_spool
table.simplenews_mail_spool()
retrieves the list, switches to the anonymous user, and initiates sending of each newsletter/recipient combination.simplenews_mail_mail()
loads the node object, adds newsletter context, and callsdrupal_mail()
to send the message.- After adding some default headers,
drupal_mail()
callssimplenews_mail()
to apply module-specific formatting. simplenews_mail()
callssimplenews_build_node_mail()
- 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. _simplenews_headers()
adds Simplenews-specific headers to the message.node_view($node, 'email_plain')
converts the node object to a FAPI render array.- The
simplenews_field
theme key is applied to each field in the render array. theme('simplenews_newsletter_body', ...)
converts the render array to HTML message body text.theme('simplenews_newsletter_footer', ...)
converts the same render array to HTML message footer text.- If plaintext output is selected,
simplenews_html_to_text()
converts the message body from HTML to plaintext. drupal_mail()
callsHTMLMailSystem::format()
to format the message.- If the Mail MIME module is enabled,
HTMLMailSystem::formatMailMIME()
uses theMailMIME
class functions to parse the message body into MIME parts, convert referenced images into inline attachments, and extract the text/html message part. theme('htmlmail', $message)
applies thehtmlmail--simplenews.tpl.php
template to add custom theming.mailsystem_html_to_text
creates a plaintext alternative to the templated output.- If the Echo module is enabled, the
echo_themed_page()
passes the message body, title, and theme as POST arguments todrupal_http_request()
, which loads theurl('echo')
page to wrap the themed, templated message body in a mail-specific themed page. - 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. 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.