public function SparkpostMailSystem::format in Sparkpost email 7.2
Same name and namespace in other branches
- 7 includes/sparkpost.mail.inc \SparkpostMailSystem::format()
Concatenate and wrap the email body for either plain-text or HTML emails.
Parameters
array $message: A message array, as described in hook_mail_alter().
Return value
array The formatted $message.
Overrides MailSystemInterface::format
File
- includes/
sparkpost.mail.inc, line 22 - Implements Sparkpost as a Drupal MailSystemInterface
Class
- SparkpostMailSystem
- Modify the drupal mail system to use Sparkpost when sending emails.
Code
public function format(array $message) {
// Join the body array into one string.
if (is_array($message['body'])) {
$message['body'] = implode("\n\n", $message['body']);
}
// Sanitize email subject.
$message['subject'] = check_plain($message['subject']);
// Remove newlines.
$message['subject'] = preg_replace('/[\\r\\n]+/', '', $message['subject']);
return $message;
}