function sparkpost_get_cc in Sparkpost email 7
Same name and namespace in other branches
- 7.2 sparkpost.module \sparkpost_get_cc()
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 sparkpost_get_cc()
- SparkpostMailSystem::mail in includes/sparkpost.mail.inc 
- Send the email message.
File
- ./sparkpost.module, line 142 
- Sparkpost integration.
Code
function sparkpost_get_cc($cc, array $to) {
  $recipients = array();
  // 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(SPARKPOST_EMAIL_REGEX, $email, $matches)) {
      $email = $matches[2];
    }
    $recipients[] = array(
      'address' => array(
        'email' => $email,
        'header_to' => $header_to,
      ),
    );
  }
  return $recipients;
}