You are here

public function DefaultMailSystem::format in Mail System 6.2

Same name and namespace in other branches
  1. 6 mailsystem.module \DefaultMailSystem::format()

Concatenate and wrap the e-mail body for plain-text mails.

Parameters

$message: A message array, as described in hook_mail_alter().

Return value

The formatted $message.

Overrides MailSystemInterface::format

File

./mailsystem.module, line 548
Provide UI for controlling the mail_system variable.

Class

DefaultMailSystem
The default Drupal mail backend using PHP's mail function.

Code

public function format(array $message) {
  $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);

  // Join the body array into one string.
  if (is_array($message['body'])) {
    $message['body'] = implode("{$line_endings}{$line_endings}", $message['body']);
  }

  // Convert any HTML to plain-text.
  $message['body'] = mailsystem_html_to_text('<pre>' . $message['body'] . '</pre>');

  // Wrap the mail body for sending.
  $message['body'] = drupal_wrap_mail($message['body']);
  return $message;
}