php - how to cc

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
babakazoo
Forum Newbie
Posts: 1
Joined: Sat Sep 18, 2010 8:46 pm

php - how to cc

Post by babakazoo »

Ladies and Gentlemen,

I am a CF guy and need to figure out this cc issue with php. I have tried everthing to no avail. I need to cc with this process.php page. is it possible?

<---- start code--->

<?php
include("global.inc.php");
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
pt_register('POST','Yes');
pt_register('POST','Name');
pt_register('POST','Emaiil');
pt_register('POST','Seminar');
pt_register('POST','Phone');
pt_register('POST','Seats');
if($Name=="" || $Emaiil=="" || $Seminar=="" || $Seats=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$Emaiil)){
$error.="<li>Invalid email address entered";
$errors=1;
}
if($errors==1) echo $error;
else{
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$to = 'info@email.com' . ', ';
$to .= $Emaiil;
$message="Hi ".$Name."

INFORAMTION WAS HERE

";
$message = stripslashes($message);
mail($to,"Form Submitted by ....... | Message Here",$message,"From: email@usa.com");
?>

<---end code--->

Thank you for any help

Jeff
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: php - how to cc

Post by Jonah Bron »

Code: Select all

$recipients = array('bill@microsoft.com', 'joe@adobe.com', 'mike@oracle.com');
$recipients = implode(', ', $recipients);
mail($recipients,"Form Submitted by ....... | Message Here",$message,"From: email@usa.com\r\n" . $recipients);
First you start out with an array of recipients. You could get this from anywhere. Then you put them together with implode() with a comma and a space in between. Then they go into the "to" field.
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: php - how to cc

Post by requinix »

Code: Select all

"From: email@usa.com\r\n" . $recipients
Except for maybe that part. Either you list them in the To: or you list them in a Cc:.

Code: Select all

mail($to,"Form Submitted by ....... | Message Here",$message,"From: email@usa.com\r\nCc: " . $recipients);
almedajohnson
Forum Newbie
Posts: 7
Joined: Sun Sep 19, 2010 11:21 pm

Re: php - how to cc

Post by almedajohnson »

I am not so clear but i think you want to put cc to send email to multiple users.To add CC you can follow this function with putting corect parameters:

bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

Here is the sample code for you:
<?php
// multiple recipients
$to = 'emailid' . ', '; // note the comma
$to .= 'emailid';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';

// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

// Additional headers
$headers .= 'To: Mary <emailid>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: emailid' . "\r\n";
$headers .= 'Bcc: emailid' . "\r\n";

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

I hope this will help you
Last edited by almedajohnson on Sun Sep 19, 2010 11:30 pm, edited 1 time in total.
User avatar
Jonah Bron
DevNet Master
Posts: 2764
Joined: Thu Mar 15, 2007 6:28 pm
Location: Redding, California

Re: php - how to cc

Post by Jonah Bron »

tasairis wrote:Except for maybe that part. Either you list them in the To: or you list them in a Cc:.
:mrgreen: duh...
Post Reply