protected function LoggerMail::formatMessage in Helper 8
Formats the mail message for display.
Parameters
array $message: The mail message.
Return value
string The mail output.
1 call to LoggerMail::formatMessage()
- LoggerMail::mail in src/
Plugin/ Mail/ LoggerMail.php - Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail().
File
- src/
Plugin/ Mail/ LoggerMail.php, line 104
Class
- LoggerMail
- Defines a mail backend that captures sent messages to the logger.
Namespace
Drupal\helper\Plugin\MailCode
protected function formatMessage(array $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 = implode($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;
}