Jump to content

Trying to add a CC function to a php contact form


macrat101

Recommended Posts

I have a php contact form that works perfectly.

 

 

It has a drop down list, and the forms results are emailed to the selected drop down persons email address.

 

I want to add a Cc function to the form ... so that there is a copy, or record of all emails sent.

 

The address $to = "[email protected] is the one that I want the Cc to go to, but I don't know how to make it work.

 

 

Not sure how to do this.

 

 

Below is what I have ... how do I integrate the Cc function into the script.

 

________________________________________________________________________________________

 

$to = $_POST["to"];  if(!in_array($to,array("[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]","[email protected]"))) $to = "[email protected]";  $subject = "Order";

there are two ways to send a copy of every email to two addresses:

you could pass a cc header:

$to = $selected_email;
$subject = 'subject';
$content = 'this goes to multiple addresses';
$header  'Cc: [email protected]' . "\r\n";
mail($to,$subject,$content,$header);

Or you could use multiple recipient addresses:

$to = $selected_email.', [email protected]';
$subject = 'subject';
$content = 'this goes to multiple addresses';
mail($to,$subject,$content);

What are you using to send the mail itself? Are you using the mail() construct, or using something else like the SMTP class from PEAR?

 

If it's mail(), you need to add the CC in the extra headers for the mail. http://php.net/manual/en/function.mail.php

 

If it's anything else, you should refer to the documentation for what you're using.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.