function DevelMailLog::composeMessage

Same name in other branches
  1. 8.x-1.x src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::composeMessage()
  2. 4.x src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::composeMessage()
  3. 5.x src/Plugin/Mail/DevelMailLog.php \Drupal\devel\Plugin\Mail\DevelMailLog::composeMessage()

Converts a message array to a string.

Parameters

$message: The message array containing the body and headers.

Return value

The message as it will be printed in the file.

1 call to DevelMailLog::composeMessage()
DevelMailLog::mail in ./devel.mail.inc
Save a mail message to a file using Drupal variables and default settings.

File

./devel.mail.inc, line 34

Class

DevelMailLog
Logs mail messages to the filesystem.

Code

public function composeMessage($message) {
    $mimeheaders = array();
    $message['headers']['To'] = $message['to'];
    foreach ($message['headers'] as $name => $value) {
        $mimeheaders[] = $name . ': ' . mime_header_encode($value);
    }
    $line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
    $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;
}