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 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2012
    Posts
    65
    Thanks
    5
    Thanked 0 Times in 0 Posts

    PHP Email script

    Hello everyone, I have used this same email script close to a hundred times now on different sites. For whatever reason, this will not send the email to the CC, any suggestions?

    PHP Code:
    <?php 

    $to          
    "*************" ;
    $cc          "*************" ;
    $from          $_REQUEST['name'] ; 
    $email          $_REQUEST['email'] ;
    $comment    $_REQUEST['comment'] ;

    $headers     "From: $from";
    $headers     "Cc: $cc"
    $subject     "Online Contact Form"

    $fields = array(); 
    $fields{"name"}         = "Name"
    $fields{"email"}         = "Email";
    $fields{"comment"}         = "Comment";

    $body "We have received the following information:\n\n"
    foreach(
    $fields as $a => $b)
    $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); }

    $send mail($to$subject$body$headers);
     
    header"Location: *********************" );

    ?>
    Last edited by willscarlet; 12-21-2012 at 01:02 AM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,093
    Thanks
    51
    Thanked 506 Times in 493 Posts
    Quote Originally Posted by willscarlet View Post
    Hello everyone, I have used this same email script close to a hundred times now on different sites.

    PHP Code:
    <?php 
    $headers     
    "From: $from";
    $headers     "Cc: $cc"
    ?>
    I'd be surprised if the recipient ever saw who it's from on because you're wiping out the sender on the next line. Try changing = to .= instead but you'll also need the carriage return which typically is \r\n.

    To be honest though, I'd just use PHPMailer instead. It's a class you can find via google, include it in your script and it'll make everything a lot easier. You just set the fields you want and tell it to send. It takes care of everything else perfectly. Job done
    My helpful sig is on vacation trying to loose some weight. It got a bit fat and caused a few problems but it will be back at some point!


  •  

    Posting Permissions

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