Search code examples
wordpressemailphpmailerbcc

Bcc: using custom Wordpress mail.php contact form


I'm attempting to have a custom contact form within our Wordpress site send a Bcc to me when it sends the completed form to the recipient. The $headers section of the form looks like this:

        $headers  = 'Content-type: text/html; charset=iso-8859-1'."\r\n";
        $headers .= 'From: '.$email;

I have tried to achieve a Bcc using this:

        $headers  = 'Content-type: text/html; charset=iso-8859-1'."\r\n";
        $headers .= 'From: '.$email;
        $headers .= 'Bcc: '[email protected];

...but it only sends to the standard recipient, not the Bcc address.

Can you see what I'm doing wrong? Many thanks!


Solution

  • Try the array form of $headers -

    $headers[] = 'Content-type: text/html; charset=iso-8859-1';
    $headers[] = 'From: '.$email;
    $headers[] = 'Bcc: [email protected]';