You are here

private function SparkpostMail::allowedHeaders in Sparkpost email 8.2

Limit headers to SparkPost whitelist.

Parameters

array $headers: Array of headers.

Return value

array Array of headers.

1 call to SparkpostMail::allowedHeaders()
SparkpostMail::mail in src/Plugin/Mail/SparkpostMail.php
Sends a message composed by \Drupal\Core\Mail\MailManagerInterface->mail().

File

src/Plugin/Mail/SparkpostMail.php, line 218

Class

SparkpostMail
Sparkpost mail plugin.

Namespace

Drupal\sparkpost\Plugin\Mail

Code

private function allowedHeaders(array $headers) {
  foreach ($headers as $header => $value) {
    if (strpos($header, 'X-') === 0) {
      continue;
    }
    elseif (in_array($header, [
      'Return-Path',
      'Cc',
    ])) {

      // Only Return-Path and Cc are supported.
      // Bcc recipients will be added to recipient list automatically and
      // removed from here.
      continue;
    }
    unset($headers[$header]);
  }
  return $headers;
}