wp_mail not recognizing cc and bcc headers

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

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

and

$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:

http://codex.wordpress.org/Pluggable_Functions

I would modify the code as follows:

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

Maybe this should be reported to wordpress core dev team?

UPDATE:

Above will be fixed in WP3.2 http://core.trac.wordpress.org/changeset/18006

Leave a Comment