Problem/Motivation
Though the Mandrill API does appear to support the addition of CC and BCC recipients, this functionality is not incorporated into the Mandrill module.
See the following excerpt from the Mandrill API documentation:

From: https://mandrillapp.com/api/docs/messages.html
Proposed resolution
In MandrillMail.php, the following lines could be updated to incorporate CC and BCC recipients from mail headers:
// Extract an array of recipients.
$to = $this->mandrill->getReceivers($message['to']);
And the following function from MandrillService.php could be updated to apply the 'type' setting as needed to classify emails as either 'to', 'cc', or 'bcc'.
/**
* Helper to generate an array of recipients.
*
* @param mixed $receiver
* a comma delimited list of email addresses in 1 of 2 forms:
* user@domain.com
* any number of names <user@domain.com>
*
* @return array
* array of email addresses
*/
public function getReceivers($receiver) {
$recipients = array();
$receiver_array = explode(',', $receiver);
foreach ($receiver_array as $email) {
if (preg_match(MANDRILL_EMAIL_REGEX, $email, $matches)) {
$recipients[] = array(
'email' => $matches[2],
'name' => $matches[1],
);
}
else {
$recipients[] = array('email' => $email);
}
}
return $recipients;
}
Remaining tasks
Write the code and upload a patch for review and testing.
User interface changes
None.
API changes
None. Just that it would add support for CC and BCC addresses which Mandrill already has.
Data model changes
The $receiver variable in getReceivers would be either an string or an array. Which would have to be accounted for in the update. The update should provide a check of some kind to provide backward compatibility for string inputs.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | d8_add_support_for_cc_and_bcc-2881577-5.patch | 3.93 KB | merauluka |
| #5 | interdiff-2771577-4-5.txt | 803 bytes | merauluka |
| mandrill_cc_bcc.png | 174.48 KB | merauluka |
Comments
Comment #2
merauluka commentedAttaching patch and marking ticket as "Needs review" to kick off testing.
Comment #3
merauluka commentedUpdating patch to fix typo in comments.
Comment #4
merauluka commentedAttaching an updated patch for when an email address doesn't have a name associated with it.
Comment #5
merauluka commentedMan. I'm batting a thousand today. That last patch was only for a single commit. Fixing with complete patch.
Sheesh.
Comment #6
diogoviannaaraujo commentedThis is really important for Drupal Commerce websites.
Most of admin confirmation comes as a CC
Hope this gets merged soon
Comment #7
crizThis patch works for us!
Comment #8
diogoviannaaraujo commentedWorked for me too
Comment #9
merauluka commentedBumping this issue since it's now listed as RTBC.
Comment #10
samuel.mortensonComment #11
knyshuk.vova commentedThe patch looks good and applies successfully. +1 for RTBC.
Comment #13
rjacobsen0 commentedPatch looks great. Thanks. Committing.
Comment #14
rjacobsen0 commented