I want the script to send (cc) the message to EmailFrom also. Do I add to $EmailTo = What do I need to add? copy of form action script: // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "[EMAIL]contact@emailmarketingclient.com[/EMAIL]"; $Subject = "Free Account Setup"; $Name = Trim(stripslashes($_POST['Name'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.emailmarketingclient.com/error.html\">"; exit; } // prepare email body text $Body = ""; $Body .= "Client Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "\n"; $Body .= "Client Email: "; $Body .= $EmailFrom; $Body .= "\n"; // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=free-account-setup.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=free-account-setup.php\">"; } PHP: Thanks Dave
Try this, // get posted data into local variables $EmailFrom = Trim(stripslashes($_POST['EmailFrom'])); $EmailTo = "[EMAIL]contact@emailmarketingclient.com[/EMAIL]"; $Subject = "Free Account Setup"; $Name = Trim(stripslashes($_POST['Name'])); // validation $validationOK=true; if (Trim($EmailFrom)=="") $validationOK=false; if (Trim($Name)=="") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=http://www.emailmarketingclient.com/error.html\">"; exit; } // prepare email body text $Body = ""; $Body .= "Client Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "\n"; $Body .= "Client Email: "; $Body .= $EmailFrom; $Body .= "\n"; // headers $Header = ""; $Header .= 'From: <$EmailFrom>' . "\r\n"; $Header .= 'Cc: cc@example.com' . "\r\n"; $Header .= 'Bcc: bcc@example.com' . "\r\n"; // send email $success = mail($EmailTo, $Subject, $Body, $Header); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=free-account-setup.php\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=free-account-setup.php\">"; } PHP:
Problem is I dont know the second email until the person completes the for. The is the variable $EmailFrom= Code (markup): is the person completing the form. I thought is would be something like: $EmailTo = "contact@emailmarketingclient.com,Trim(stripslashes($_POST['EmailFrom']))"; Code (markup): But that didn't work. The listed ones above are not working also.
you can put variables inside strings but not functions. Try this $EmailTo = "contact@emailmarketingclient.com,".trim(stripslashes($_POST['EmailFrom'])); PHP:
Ah, You said CC. Not direct mail. Just add it at the $header section, see this : $Header .= 'Cc: cc@example.com,'.trim(stripslashes($_POST['EmailFrom'])) . "\r\n"; Code (markup):