Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need help adding CC to PHP Contact form

    Need help adding CC to email.

    I have a very limited knowledge of PHP programing and am attempting yo modify a script for sending an email form from my website. It works fine, but I need it to send a CC or second email to a different address.

    Here is the script:

    <?php
    $EmailTo = "myaddress@comcast.net";
    $Where = Trim(stripslashes($_POST['where']));
    $Subject = "Free Initial Consultation Request Form";
    $Tel = Trim(stripslashes($_POST['Tel']));
    $Name = Trim(stripslashes($_POST['Name']));
    $Email = Trim(stripslashes($_POST['Email']));
    $msg = Trim(stripslashes($_POST['Message']));
    $human = $_REQUEST['url'];

    $headers = "From: <$Email>\r\n";
    $headers .= "Reply-To: <$Email>\r\n";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";


    $Body = '<html><body>';
    $Body .= '<h1>Consultation Request Form</h1>';
    $Body .= '<table rules="all" style="border-color: #666;" cellpadding="10">';
    $Body .= "<tr style='background: #eee;'><td><strong>Name:</strong> </td><td>$Name</td></tr>";
    $Body .= "<tr><td><strong>Email:</strong> </td><td>$Email</td></tr>";
    $Body .= "<tr><td><strong>Telephone:</strong> </td><td>$Tel</td></tr>";
    $Body .= "<tr><td><strong>Message:</strong> </td><td>$msg</td></tr>";
    $Body .= "</table>";
    $Body .= '</body></html>';

    if ($human != "") {print "Apparently you are not human";}
    else {
    if($Name == '') {print "You have not entered a name, please go back and try again";}
    else {
    if($Email == '') {print "You have not entered an email, please go back and try again";}
    else {
    if($Tel == '') {print "You have not entered a telephone number, please go back and try again";}
    else {
    $success = mail($EmailTo, $Subject, $Body, $headers);
    }
    }
    }
    }
    if ($success){
    print "<meta http-equiv=\"refresh\" content=\"0;URL=contactthanks.html\">";
    }

    ?>

    I tried adding a cc to the header
    with this coding:

    $headers .= "Cc: someone@domain.com \r\n";

    But it did not work.

    Any help you can give will be appreciated.

    Thanks

  • #2
    bdl
    bdl is offline
    Regular Coder
    Join Date
    Apr 2007
    Location
    Camarillo, CA US
    Posts
    590
    Thanks
    4
    Thanked 83 Times in 82 Posts
    Based on the examples on PHP's site, your CC header looks correct, although I would remove the space between the email address and the \r\n.

  • #3
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Thanks, I removed the space and the form processes correctly


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •