You are here

protected function DevelMailLog::composeMessage in Devel 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::composeMessage()
  2. 8.2 src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::composeMessage()
  3. 4.x src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::composeMessage()

Compose the output message.

Parameters

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

Return value

string The output message.

1 call to DevelMailLog::composeMessage()
DevelMailLog::mail in src/Plugin/Mail/DevelMailLog.php
Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail().

File

src/Plugin/Mail/DevelMailLog.php, line 123

Class

DevelMailLog
Defines a mail backend that saves emails as temporary files.

Namespace

Drupal\devel\Plugin\Mail

Code

protected function composeMessage($message) {
  $mimeheaders = [];
  $message['headers']['To'] = $message['to'];
  foreach ($message['headers'] as $name => $value) {
    $mimeheaders[] = $name . ': ' . Unicode::mimeHeaderEncode($value);
  }
  $line_endings = Settings::get('mail_line_endings', PHP_EOL);
  $output = join($line_endings, $mimeheaders) . $line_endings;

  // 'Subject:' is a mail header and should not be translated.
  $output .= 'Subject: ' . $message['subject'] . $line_endings;

  // Blank line to separate headers from body.
  $output .= $line_endings;
  $output .= preg_replace('@\\r?\\n@', $line_endings, $message['body']);
  return $output;
}