Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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 = "sender@example.com";
public $replyTo = "sender@example.com";
public $bcc = "bccaddress@example.com";

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

wp_mail("example@example.com", "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

share|improve this question
    
@EAMann I didn't create that question that I referenced, which is why I opened a new one. –  J Lee Mar 20 '12 at 22:11
    
a different guy opened that one mate.. check the name.. ahh never mind @fewpeople - you should do it like this in your wp_mail line: wp_mail(array($replyTo, $bcc), "My Subject Line" , $html, $headers); - You can even add more if you want... hope this helps :) –  Sagive SEO Mar 20 '12 at 22:17
    
@fewpeople My mistake ... reopening. –  EAMann Mar 20 '12 at 22:42
    
@SagiveSEO Can someone confirm this? –  AlxVallejo Jul 23 '12 at 16:22

1 Answer 1

up vote 3 down vote accepted

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.

share|improve this answer
    
Here's what I got for the bcc section private 'bcc' => array 0 => array 0 => string 'mybccaddress@example.com' (length=19) 1 => string 'Frank' (length=5)' –  J Lee Mar 21 '12 at 9:54
    
Ok, this tells us that it's empty. But please keep this filter alive to monitor your changes... Ehm, and thanks for editing the comment. Much more readable :) Now the question is: How exactly does your current setup look like? (Update Q). –  kaiser Mar 21 '12 at 9:57
1  
What information in particular of the setup would you like to look at, I can provide as much info as needed. –  J Lee Mar 21 '12 at 10:02
    
Ah, no more info needed, I guess you'll get around this yourself. Please go into core, /wp-includes/pluggable.php ~Line#235 (WP 3.3.1) and starting with some var_dump() of $header. If it's empty, then go up and try to find the point, where your BCC is lost. –  kaiser Mar 21 '12 at 10:15
1  
Your question in regards to looking at the setup led me to find out what the problem was. I'm using a program called Papercut, which is a simplified SMTP server for receiving messages. Papercut doesn't show BCC addresses as it keeps it hidden. So the only way to test BCC is using your debug function and making sure that the BCC section of the var_dump($phpmailer) has the addresses you want to send to. Alas, I feel stupid as this isn't a WP problem, but the case is solved. –  J Lee Mar 21 '12 at 11:01

Your Answer

 
discard

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.