Skip to content
PHP Logo

How can you include cc and bc in the header of a form mailer using PHP?

To include cc and bcc in the header of a form mailer using PHP, you can use the "cc" and "bcc" parameters in the mail() function. Simply add the email addresses you want to cc or bcc to as values for these parameters. This allows you to send a copy of the email to additional recipients without them being visible to the main recipient.

php
$to = "recipient@example.com";
$subject = "Subject";
$message = "Message";

$headers = "From: sender@example.com\r\n";
$headers .= "Cc: cc@example.com\r\n";
$headers .= "Bcc: bcc@example.com\r\n";

mail($to, $subject, $message, $headers);