Page 1 of 1

php - how to cc

Posted: Sun Sep 19, 2010 12:55 pm
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

Re: php - how to cc

Posted: Sun Sep 19, 2010 5:06 pm
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.

Re: php - how to cc

Posted: Sun Sep 19, 2010 10:13 pm
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);

Re: php - how to cc

Posted: Sun Sep 19, 2010 11:29 pm
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

Re: php - how to cc

Posted: Sun Sep 19, 2010 11:30 pm
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...