public function NewsletterMailSystem::format in Newsletter 7
Same name and namespace in other branches
- 7.2 includes/newsletter.mail.inc \NewsletterMailSystem::format()
 
Format a message composed by drupal_mail() prior sending.
Parameters
$message: A message array, as described in hook_mail_alter().
Return value
The formatted $message.
Overrides MailSystemInterface::format
File
- includes/
newsletter.mail.inc, line 44  - Class file for MailSystemInterface implementation.
 
Class
- NewsletterMailSystem
 - Modify the drupal mail system to send HTML emails.
 
Code
public function format(array $message) {
  $message['body'] = implode("\n\n", $message['body']);
  // Format the body according to text format
  // or strip all the tags if email format is plain text
  if (!empty($message['body'])) {
    // Add query to all urls so we can gather clicks
    $message['body'] = $this
      ->addNewsletterUrlQuery($message);
    $message['body'] = $message['format'] == 'html' ? check_markup($message['body'], $message['body_format']) : strip_tags($message['body']);
    // Remove empty tokens
    $message['body'] = token_replace($message['body'], array(), array(
      'clear' => TRUE,
    ));
  }
  if (!empty($message['subject'])) {
    $message['subject'] = strip_tags($message['subject']);
    // Remove empty tokens here as well
    $message['subject'] = token_replace($message['subject'], array(), array(
      'clear' => TRUE,
    ));
  }
  return $message;
}