I am not sure if this is me or the CC and BCC do not work. Debugging $message in htmlmail_mail() I see that the headers do not contain my CC and BCC that I sent with the $params.
My code to send mail is:

$params = array (
    'subject' => $subject,
    'body' => check_markup($body_text, 'full_html'),
    'headers' => array('Cc' => $cc, 'Bcc' => $bcc),
  );
drupal_mail('htmlmail', $module, $to, language_default(), $params, $from);

I added a line in htmlmail_mail() as follows:

$message['headers'] = array_merge($message['headers'], $params['headers']);

and it seems to work for me. Am I doing it wrong? Is this already in place somewhere and I am not using it correctly?

Comments

unqunq’s picture

Issue summary: View changes
badjava’s picture

Status: Active » Needs review
StatusFileSize
new367 bytes

I had the same issue and fixed it with the suggestion above. Attached is the patch.

badjava’s picture

Added an isset() to ensure the headers exist first before merging.

Utkarsh_Mishra’s picture

Assigned: Unassigned » Utkarsh_Mishra
Status: Needs review » Reviewed & tested by the community
salvis’s picture

Version: 7.x-2.65 » 7.x-2.70
Assigned: Utkarsh_Mishra » Unassigned
Status: Reviewed & tested by the community » Needs review

This needs to be tested against 2.70, and I'd like to get some more review feedback.

Please don't assign yourself unless you want to signal that you're actively working on an issue.

salvis’s picture

Version: 7.x-2.70 » 8.x-3.x-dev

Ok, this looks reasonable. Does it already work in D8?

Vidushi Mehta’s picture

StatusFileSize
new27.14 KB

#3 Does not apply on 8.x-3.x-dev but the code which was added by #3 is already there in the module file. So I think this issue should be closed and committed. Added a screenshot.

salvis’s picture

Version: 8.x-3.x-dev » 7.x-2.x-dev

Thank you for checking this, Vidushi Mehta!

  • salvis committed e639f3a on 7.x-2.x
    Issue #2348929 by badjava, unqunq: Fix custom headers not added in (cc,...
salvis’s picture

Status: Needs review » Fixed
Issue tags: -custom http headers

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

q11q11’s picture

Adding pach for format() method, which also was not storing custom headers passed with $message['params']['headers'].
Solution is same as in #3.
Made it against current 7.x-2.x (@e21f912).