You are here

public function PhpMail::format in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php \Drupal\Core\Mail\Plugin\Mail\PhpMail::format()

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 MailInterface::format

1 method overrides PhpMail::format()
TestHtmlMailCollector::format in core/modules/system/tests/modules/mail_html_test/src/Plugin/Mail/TestHtmlMailCollector.php
Concatenates and wraps the email body for plain-text mails.

File

core/lib/Drupal/Core/Mail/Plugin/Mail/PhpMail.php, line 52

Class

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

Namespace

Drupal\Core\Mail\Plugin\Mail

Code

public function format(array $message) {

  // Join the body array into one string.
  $message['body'] = implode("\n\n", $message['body']);

  // Convert any HTML to plain-text.
  $message['body'] = MailFormatHelper::htmlToText($message['body']);

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