function SymfonyMailer::format

Same name in other branches
  1. 11.x core/lib/Drupal/Core/Mail/Plugin/Mail/SymfonyMailer.php \Drupal\Core\Mail\Plugin\Mail\SymfonyMailer::format()

Overrides MailInterface::format

File

core/lib/Drupal/Core/Mail/Plugin/Mail/SymfonyMailer.php, line 100

Class

SymfonyMailer
Defines an experimental mail backend, based on the Symfony mailer component.

Namespace

Drupal\Core\Mail\Plugin\Mail

Code

public function format(array $message) {
    foreach ($message['body'] as &$part) {
        // If the message contains HTML, convert it to plain text (which also
        // wraps the mail body).
        if ($part instanceof MarkupInterface) {
            $part = MailFormatHelper::htmlToText($part);
        }
        else {
            $part = MailFormatHelper::wrapMail($part);
        }
    }
    // Join the body array into one string.
    $message['body'] = implode("\n\n", $message['body']);
    return $message;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.