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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cc: PHP form processing of cc field 1

Status
Not open for further replies.

jollydonkey

Technical User
Sep 5, 2008
23
CA
Hello,

I'm trying to use php to send a form to 2 cc recipients (the original form filler and an assigned person). While the $to person receives the email, the cc fields are blank. What could I possibly be doing wrong with my code below?

Code:
$email = $_POST['email'];
$cc    = $_POST['cc'];

$headers = "From:$email\r\n";
$headers .= "CC:$cc\r\n"; 

$to = 'me@me.com';
$cc = $cc + "," + $email;

mail($to, $cc, $subject, $message, $headers);

Thanks!

Cheers,
Dipesh.
 
well, the first thing you are doing wrong is misusing the mail() function.
manual said:
bool mail ( string $to , string $subject , string $message [, string $additional_headers [, string $additional_parameters ]] )

perhaps something like this

Code:
$email = $_POST['email'];
$cc    = $_POST['cc'];
$cc = $cc + "," + $email;
$headers = "From:$email\r\n";
$headers .= "CC:$cc\r\n";

$to = 'me@me.com';


mail($to,$subject, $message, $headers);
 
Thanks - I tried that (by eliminating the $cc in the mail function), however, I get a 0 in the CC field when the email is generated.

I'm totally stumped and open to ideas.
 
well, that's probably because you are trying to concatenate using a PLUS sign. this is javascript. in php you use a DOT to concatenate.

Code:
$cc = $cc [red].[/red] "," [red].[/red] $email;
 
Gosh, how embarrassing. My newbiness is so out there. Thanks for helping me out here! Much appreciated.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top