PHP mail Multiple BCC:

Hi

The PHP manual does not tell me anything about it so I thought this is the best place to ask.

Does the PHP Mail function allow multiple recipent either in TO or CC or BCC separated by comma?

For example


<?php
mail('nobody@example.com,me@myserver.com,you@gmail.com,sam@email.com', 'the subject', 'the message', null,
   '-fwebmaster@example.com');
?>


OR


<?php

$headers  = 'MIME-Version: 1.0' . "\\r\
";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\\r\
";

// Additional headers
$headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\\r\
";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\\r\
";
$headers .= 'Cc: [email]birthdayarchive@example.com[/email]' . "\\r\
";
$headers .= 'Bcc: [email]birthdaycheck@example.com,me@myserver.com,you@gmail.com,sam@email.com[/email]' . "\\r\
";

// Mail it
mail($to, $subject, $message, $headers);
?>


Thanks for your input.


yes it does seperated by a comma.


$toaddress = 'email1@123.com,email2@123.com,'.$email3;

for some reason, it does not work for me… :frowning:

I’ve not seen you full code, but below is a working sample that you can use or customize to your needs.


<html>
<head>
<title></title>
<style type="text/css">
<!--
.row1{
	font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
	font-size:11px;
	font-type:normal;
	padding:2px;
	background-color:#E6E6E6;}
.row2{
	font-family: Verdana, Geneva, Arial, helvetica, sans-serif;
	font-size:11px;
	font-type:normal;
	padding:2px;
	background-color: #F2F2F2;}
-->
</style>
</head>
<body>
<?php

//check that variables filled
if(isset($_POST['submit']))
	{

	//request type
	$test = trim($_POST['test']);
	$test2 = trim($_POST['test2']);
	$test3 = trim($_POST['test3']);
				


$recipient2=$email;
$toaddress = 'email_1@123.com,email_2@123.com';


$subject = 'subject: ';
$mailcontent = 'test: '.$test."\
"
			   .'test2: '.$test2."\
"
			   .'Wtest3: '.$test3."\
";
			   



$fromaddress  = "From: 123@123.com,\\r\
";
$fromaddress  .="BCC: 123@123.com,1235@123.com\\r\
";
//prototype is mail(string to, string subject, string message, string additional_headers, string additional_parameters)
mail($toaddress, $subject, $mailcontent, $fromaddress);


if(!mail)
	{
		echo'<table width="100&#37;" border="0" cellpadding="5" cellspacing="0">
			<tr align="center">
			<td colspan="1" align="left">
			<img src="mpsgi.gif" border="0"></td>
			<tr />
			<td>
			<font size="6">Email Form</font>
			</td>
			<tr />
			<td>&nbsp;</td>
			<tr />
			<td>There was a problem sending your email: </td>
			</table>';
		exit;
	}
	else
	{
	
	echo'<table width="100%" border="0" cellpadding="5" cellspacing="0">
			<tr align="center">
			<td colspan="1" align="left">
			<img src="mpsgi.gif" border="0"></td>
			<tr />
			<td>
			<font size="6">Change Control Form</font>
			</td>
			<tr />
			<td>&nbsp;</td>
			<tr />
			<td>Thank you for email.</td><tr><td><b>Date: </b>'; 
			echo'</td>';
			echo'</tr>
			</table>';
		exit;
	}
	
}
?>

</body>
</html>

Please provide the code you are using to better assist you.

Now sure how, but your code worked!

Thanks for showing your magic :slight_smile:

hi! maybe i can help you with this just i will send you pm maybe we can discuss it on im.