You are here

public function HTMLMailSystem::txtHeaders in HTML Mail 8

Same name and namespace in other branches
  1. 8.3 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 473

Class

HTMLMailSystem
Modify the Drupal mail system to use HTMLMail 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);
}