private function SparkpostMail::createCcField in Sparkpost email 8.2
Get list of cc recipients.
Parameters
string $cc: Comma separated list of Cc recipients.
array $to: List of recipients created by sparkpost_get_to().
Return value
array List of recipients to merged with sparkpost_get_to() results.
1 call to SparkpostMail::createCcField()
- 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 276
Class
- SparkpostMail
- Sparkpost mail plugin.
Namespace
Drupal\sparkpost\Plugin\MailCode
private function createCcField($cc, array $to) {
$recipients = [];
// Explode recipient list.
$cc_array = explode(',', $cc);
// Prepare header_to value.
$header_to = implode(',', array_map(function ($recipient) {
return $recipient['address']['email'];
}, $to));
foreach ($cc_array as $email) {
if (preg_match(ClientService::EMAIL_REGEX, $email, $matches)) {
$email = $matches[2];
}
$recipients[] = [
'address' => [
'email' => $email,
'header_to' => $header_to,
],
];
}
return $recipients;
}