Sending a Simplenews Newsletter via HTML Mail
Last updated on
30 April 2025
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_spooltable.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_fieldtheme 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 theMailMIMEclass 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.phptemplate to add custom theming.mailsystem_html_to_textcreates 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.
Help improve this page
Page status: Not set
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion