Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP mail() multiple recipients

Status
Not open for further replies.

rrsub

MIS
Joined
Oct 23, 2002
Messages
536
Location
US
I have a single php script that a user edits this array for email addresses;

<?PHP
$Sent_to[0] = "him@domain.com";
$Sent_to[1] = "her@domain.com";
$Sent_to[2] = "friend@domain.com";
$Sent_to[3] = "boss@domain.com";
?>

I have the script where it takes [1] to [3] and makes Cc: <emailaddress> \r\n

When I mail, it only sends the to [0] and the [1].
 
$to = $Sent_to[0];

$headers = "".
"Content-Type: text/plain \r\n".
"Date: ".date("r")."\r\n".
"Return-Path: administrator@mydomain.com \r\n".
"From: ".$From."\r\n".
"Sender: ".$From."\r\n".
"Reply-to: ".$Sent_to[0]."\r\n".
"Organization: mydomain.com\r\n".
"X-Sender: ".$From."\r\n".
"X-Priority: 3 \r\n".
"X-Mailer: AFFSP \r\n";
if($Sent_to[1])
{
$i=1;
while($Sent_to[$i])
{
$headers .= "Cc: ".$Sent_to[$i]."\r\n";
$i++;
}
echo $headers; // for debug
}

## Further down as the message is created

mail($to, $subject, $message, $headers);
 
Fixed it.

if($Sent_to[1])
{
$i=1;
$headers .= "Cc: ";
while($Sent_to[$i])
{
$headers .= " ".$Sent_to[$i].",";
$i++;
}
$headers .= "\r\n";
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top