Sign up ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using WordPress 3.1.3

I am getting following notices when I use wp_mail with cc and bcc headers.

Notice: Undefined variable: cc in /var/www/ on line 349 
Notice: Undefined variable: bcc in /var/www/ on line 352 

This is how I am setting email headers

$email_headers  = "From: ".$from_field_value.PHP_EOL;
$email_headers .= "Reply-To: ".$from_field_value.PHP_EOL;
$email_headers .= "CC:".PHP_EOL;
$email_headers .= "BCC:".PHP_EOL;

if (wp_mail($email_to, $email_subject, $email_body, $email_headers)) {
      // Other process
share|improve this question

1 Answer 1

If you look at the line the notice is being issued:

$cc = array_merge( (array) $cc, explode( ',', $content ) );


$bcc = array_merge( (array) $bcc, explode( ',', $content ) );

What its trying to do is merge a blank array that hasn't been set with an array created by your headers.

The notice can be ignored. After all its just a notice.

As this function is pluggable you can copy the function and place in a plugin file and correct the code. That way you are not editing core files. See pluggable functions:

I would modify the code as follows:

case 'cc':
    if (!isset($cc))
        $cc = array();
    $cc = array_merge( $cc, explode( ',', $content ) );
case 'bcc':
    if (!isset($bcc))
        $bcc = array();
    $bcc = array_merge( $bcc, explode( ',', $content ) );

Maybe this should be reported to wordpress core dev team?


Above will be fixed in WP3.2

share|improve this answer
You are inside the loop of headers, variables might not be set first time but will be set on following iterations. I am not proficient with header mechanics, but better fix would be to init $cc and $bcc to empty arrays, rather than remove them. –  Rarst Jun 28 '11 at 9:25
@Rarst - modified code. Is this better? –  Brady Jun 28 '11 at 9:46
Yep, seems better to me. –  Rarst Jun 28 '11 at 9:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.