Add bcc PHP mail function

user3377272 picture user3377272 · Mar 4, 2014 · Viewed 22.1k times · Source

Currently this is how the headers look like. What should I do if I want to add a bcc. Thanks for the help. Below is what the code looks like.

// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers); 
?>

Answer

Carl Markham picture Carl Markham · Mar 4, 2014

You would add this in the headers:

'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'Bcc: [email protected]' . "\r\n" . 
'X-Mailer: PHP/' . phpversion();

As shown on the docs at PHP.net