You are here

public function HtmlMailSystem::txtHeaders in HTML Mail 8.3

Same name and namespace in other branches
  1. 8 src/Plugin/Mail/HTMLMailSystem.php \Drupal\htmlmail\Plugin\Mail\HTMLMailSystem::txtHeaders()

Converts an array of email headers to a text string.

Parameters

array $headers: An associative array of ('HeaderName' => 'header value') pairs.

Return value

string The concatenated headers as a single string.

1 call to HtmlMailSystem::txtHeaders()
HtmlMailSystem::mail in src/Plugin/Mail/HtmlMailSystem.php
Send an email message.

File

src/Plugin/Mail/HtmlMailSystem.php, line 537

Class

HtmlMailSystem
Modify the Drupal mail system to use HTML Mail when sending emails.

Namespace

Drupal\htmlmail\Plugin\Mail

Code

public function txtHeaders(array $headers) {
  $output = [];
  foreach ($headers as $name => $value) {
    if (is_array($value)) {
      foreach ($value as $val) {
        $output[] = "{$name}: {$val}";
      }
    }
    else {
      $output[] = "{$name}: {$value}";
    }
  }
  return implode("\n", $output);
}