The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> How to add a CC: to mail.php
larry78723
post Mar 22 2020, 08:29 AM
Post #1


Member
***

Group: Members
Posts: 39
Joined: 5-March 20
Member No.: 27,220



The following code works well but I'd like to add a cc: to $email. I think, but not sure, that I'll have to create an array[] to contain $recipient and $email and I don't know how to include the array[] in the "mail($recipient, $subject, $formcontent, $mailheader)". Can someone help me out on this?

CODE
<?php
$subject = $_POST['type'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent=" From: $name  \n  Message: $message";
if ($subject =="Website Problem") {
        $recipient="webmaster@foxclone.com";
      }
else{
        $recipient="andyh@foxclone.com";
      }
$mailheader = "From: $email \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='index3.php' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>


Thanks in advance,
Larry
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
larry78723
post Mar 22 2020, 01:25 PM
Post #2


Member
***

Group: Members
Posts: 39
Joined: 5-March 20
Member No.: 27,220



Got it working like this:

<?php
$subject = $_POST['type'];
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$formcontent=" From: $name \n Message: $message";
if ($subject =="Website Problem") {
$recipient="webmaster@foxclone.com";
}
else{
$recipient="andyh@foxclone.com";
}
$mailheader = "From: $email\r\nBcc: $email\r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "Thank You!" . " -" . "<a href='index3.php' style='text-decoration:none;color:#ff0099;'> Return Home</a>";
?>
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
larry78723
post Mar 22 2020, 01:26 PM
Post #3


Member
***

Group: Members
Posts: 39
Joined: 5-March 20
Member No.: 27,220



Was duplicate post. Sorry! sad.gif

This post has been edited by larry78723: Mar 22 2020, 01:31 PM
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 19th March 2024 - 02:07 AM