You are here

public function MimeMail::format in Mime Mail 8

Concatenates and wraps the email body for plain-text mails.

Parameters

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

Return value

array The formatted $message.

Overrides PhpMail::format

File

src/Plugin/Mail/MimeMail.php, line 92

Class

MimeMail
Defines the default Drupal mail backend, using PHP's native mail() function.

Namespace

Drupal\mimemail\Plugin\Mail

Code

public function format(array $message) {
  if (is_array($message['body'])) {
    $message['body'] = implode("\n\n", $message['body']);
  }
  if (preg_match('/plain/', $message['headers']['Content-Type'])) {
    if (!($format = $this->configFactory
      ->get('mimemail.settings')
      ->get('format'))) {
      $format = filter_fallback_format();
    }
    $langcode = isset($message['langcode']) ? $message['langcode'] : '';
    $message['body'] = check_markup($message['body'], $format, $langcode);
  }
  $message = $this
    ->prepareMessage($message);
  return $message;
}