You are here

public function SMTPMailSystem::format in SMTP Authentication Support 8

Concatenate and wrap the e-mail 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 MailInterface::format

File

src/Plugin/Mail/SMTPMailSystem.php, line 170

Class

SMTPMailSystem
Modify the drupal mail system to use smtp when sending emails.

Namespace

Drupal\smtp\Plugin\Mail

Code

public function format(array $message) {
  $this->AllowHtml = $this->smtpConfig
    ->get('smtp_allowhtml');

  // Join the body array into one string.
  $message['body'] = implode("\n\n", $message['body']);
  if ($this->AllowHtml == 0) {

    // 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;
}