You are here

public function DrupalPHPMailer::format in PHPMailer 8.3

Concatenates and wraps the e-mail body for plain-text mails.

Mails contain HTML by default. When using PHPMailer without MimeMail module, plain-text e-mails are sent, which require the same processing as in the DefaultMailSystem implementation.

Parameters

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

Return value

The formatted $message.

Overrides MailInterface::format

See also

DefaultMailSystem::format()

File

src/Plugin/Mail/DrupalPHPMailer.php, line 253

Class

DrupalPHPMailer
Implements the base PHPMailer class for the Drupal MailInterface.

Namespace

Drupal\phpmailer\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;
}