You are here

public function MailMIME::toEmail in Mail MIME 6.2

Same name and namespace in other branches
  1. 8.2 mailmime.inc \MailMIME::toEmail()
  2. 6 mailmime.inc \MailMIME::toEmail()
  3. 7.2 mailmime.inc \MailMIME::toEmail()
  4. 7 mailmime.inc \MailMIME::toEmail()

Return a (headers, body) pair for sending.

Merge the $headers parameter with the MIME headers and return it with the fully-encoded message body.

Parameters

$headers: The original message headers array.

Return value

array An array containing two elements, the merged headers and the fully- encoded message body, both ready to send.

File

./mailmime.inc, line 689
Provides the MailMIME class for creating MIME-formatted email messages.

Class

MailMIME
The MailMIME class is used to create MIME email messages.

Code

public function toEmail($headers) {
  $headers = self::toHeaders($headers);
  $mime_headers = $this
    ->headers();

  // Drupal core does not handle correctly the \n before 'boundary' that
  // mime.php inserts.
  if (!empty($mime_headers['Content-Type'])) {
    $mime_headers['Content-Type'] = preg_replace('/\\n/', ' ', $mime_headers['Content-Type']);
  }
  return array(
    array_diff_key($headers, $mime_headers) + $mime_headers,
    $this
      ->get(NULL, NULL, TRUE),
  );
}