I'm using the below code to add an Email address to the CC field of the 'customer_refunded_order' and 'customer_partially_refunded_order' Email in WooCommerce.
But eventhough I see the CC header information in the Email, the Email is not delivered to the CC Email address (also no in spam folder), eventhough it is delivered to the default Email address.
function add_cc_to_certain_emails( $headers, $object ) {
// email types/objects to add bcc to
// Comment out what you don't need
$add_bcc_to = array(
'customer_refunded_order',
'customer_partially_refunded_order',
);
// Prepare the the data
$formatted_email = utf8_decode('mrbean@gmail.com');
// if our email object is in our array
if ( in_array( $object, $add_bcc_to ) ) {
// Change our headers
$headers = array(
$headers,
'Cc: '.$formatted_email ."\r\n",
);
}
return $headers;
}
add_filter( 'woocommerce_email_headers', 'add_cc_to_certain_emails', 10, 2 );
Could anyone please help me with this?
I've already tried disabling all other plugins then WooCommerce and using a default WordPress theme. I also already tried to change the cc Email address to something else then Gmail, but also that doesn't help.
Thanks for your help all!