You are here

protected function SMTPMailSystem::applyRerouting in SMTP Authentication Support 8

Applies rerouting, if an address is set for that purpose.

Parameters

string $to: Original $to address.

array $headers: Original headers for the message.

Return value

array Keyed array, with new values for $to and $headers, after potentially applying rerouting.

2 calls to SMTPMailSystem::applyRerouting()
SMTPMailSystem::mail in src/Plugin/Mail/SMTPMailSystem.php
Send the e-mail message.
SMTPMailSystemTestHelper::publicApplyRerouting in tests/src/Unit/Plugin/Mail/SMTPMailSystemTest.php
Exposes applyRerouting() for testing.

File

src/Plugin/Mail/SMTPMailSystem.php, line 846

Class

SMTPMailSystem
Modify the drupal mail system to use smtp when sending emails.

Namespace

Drupal\smtp\Plugin\Mail

Code

protected function applyRerouting($to, array $headers) {
  $new_to = $to;
  $new_headers = $headers;
  $reroute_address = $this->smtpConfig
    ->get('smtp_reroute_address');
  if (!empty($reroute_address)) {
    $new_to = $reroute_address;

    // Remove any CC and BCC headers that might have been set.
    unset($new_headers['cc']);
    unset($new_headers['bcc']);
  }
  return [
    $new_to,
    $new_headers,
  ];
}