Jump to content

Trying to add a CC function to a php contact form


macrat101
 Share

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 = "support@xxx.com 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("ian@xxx.com","adam@xxx.com","keith@xxx.com","sue@xxx.com","mark@xxx.com","scott@xxx.com","joyce@xxx.com","joe@xxx.com","ken@xxx.com","info@xxx.com"))) $to = "support@xxx.com";  $subject = "Order";

Link to comment
Share on other sites

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: sendcopyto@test.com' . "\r\n";
mail($to,$subject,$content,$header);

Or you could use multiple recipient addresses:

$to = $selected_email.', sendcopyto@test.com';
$subject = 'subject';
$content = 'this goes to multiple addresses';
mail($to,$subject,$content);

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • 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.