PHP mail BCC, send email function?

PHP mail BCC, send email function?

Here you have a great example of how to add BCC to your PHP email code.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
$email = 'cristiweb2@gmail.com';
$to = 'cristiweb2@gmail.com';
$bcc = 'test@website.com';
$subject = 'New message';
$body = '
From: '.$name.'
Email: '.$email.'
Phone number: '.$phone.'
 
Message: '.$message.'
';
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: '.$email.'' .  "\r\n";
	$headers .= 'Bcc: '.$bcc.'' . "\r\n";
mail($to, $subject, $body, $headers);
?>

As you see, the code is pretty similar to normal emails in php, you just need to add the new variable $bcc and integrate it in the $headers var.

Add a comment: