wp_mail and BCC headers

I’m using WP 3.3.1

I am trying to add BCC onto the headers of an email I’m sending out, but the BCC is not being added.

public $from = "[email protected]";
public $replyTo = "[email protected]";
public $bcc = "[email protected]";

$headers['From']    = "From: ".$this->from;       
$headers['Reply-To'] = "Reply-To: ".$this->replyTo;
$headers['Bcc'] = "Bcc: ".$this->bcc;

wp_mail("[email protected]", "My Subject Line" , $html, $headers);

I’ve looked at this article, which says the problem was suppose to be fixed in WP 3.2…but for me, it’s still not working.

I am using a local SMTP server application called Papercut to monitor the emails that are being sent.

Related: wp_mail not recognizing cc and bcc headers

1
1

You could try to debug the output like this:

function test_phpmailer_init( $phpmailer )
{
    echo '<pre>';
        var_dump( $phpmailer );
    echo '</pre>';
    return $phpmailer;
}
add_action( 'phpmailer_init', 'test_phpmailer_init' );

The code in your question is correct, the problem is with your local SMTP application. If you are using a local SMTP server (e.x. Papercut), it only displays the headers that a receiver would see. Since BCC addresses are hidden, you will not see them. So to check to see if BCC addresses are being attached, you can use the function I’ve listed above which will spit out the mail output.

Leave a Comment