Printable Version of Topic

Click here to view this topic in its original format

HTMLHelp Forums _ Server-side Scripting _ How to add a CC: to mail.php

Posted by: larry78723 Mar 22 2020, 08:29 AM

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

Posted by: larry78723 Mar 22 2020, 01:25 PM

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>";
?>

Posted by: larry78723 Mar 22 2020, 01:26 PM

Was duplicate post. Sorry! sad.gif

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)