0

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: '.myemail@email.com;

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

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

JoeW
  • 578
  • 1
  • 10
  • 29
  • 1
    This approach is very fragile - you're not applying any of the encoding needed for these headers, so it's quite likely to break with some user input. That's why libraries like PHPMailer (as Wordpress uses) exist, but you're bypassing all that. – Synchro Apr 08 '15 at 21:07
  • What I ended up using in the end was: `$headers = "From: .get_bloginfo('name').' <'.get_option('admin_email').'>'.\r\nReply-to: $email\r\nBcc: myemail@email.com";` – JoeW Apr 08 '15 at 21:23

1 Answers1

1

Try the array form of $headers -

$headers[] = 'Content-type: text/html; charset=iso-8859-1';
$headers[] = 'From: '.$email;
$headers[] = 'Bcc: myemail@email.com';
johnnyd23
  • 1,665
  • 2
  • 13
  • 24