phpemailbcc

Add bcc PHP mail function


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); 
?>

Solution

  • You would add this in the headers:

    'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'Bcc: someone@example.com' . "\r\n" . 
    'X-Mailer: PHP/' . phpversion();
    

    As shown on the docs at PHP.net