foxhill Posted August 13, 2008 Share Posted August 13, 2008 I am using the below (very simple) code to process a contact form. However, I cannot figure out how to have the email say it is from the user's email address. The address is entered in the form in a field called "email". What do I need to add to resolve this issue? <?PHP $to = "[email protected]"; $subject = "xyz"; $headers = ""; $forward = 1; $location = "http://www.fghijk.com/"; $date = date ("l, F jS, Y"); $time = date ("h:i A"); $msg = "Below is your request confirmation. It was submitted on $date at $time.\n\n"; if ($_SERVER['REQUEST_METHOD'] == "POST") { foreach ($_POST as $key => $value) { $msg .= ucfirst ($key) ." : ". $value . "\n"; } } else { foreach ($_GET as $key => $value) { $msg .= ucfirst ($key) ." : ". $value . "\n"; } } mail($to, $subject, $msg, $headers); if ($forward == 1) { header ("Location:$location"); } else { echo "Thank you for subscribing to our newsletter. We will add you to our mailing list as soon as possible."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/119464-question-about-simple-mailer-script/ Share on other sites More sharing options...
spasme Posted August 13, 2008 Share Posted August 13, 2008 $headers should look somethink like this: $headers="From: ".$yourname." <".$youremail.">\n"; $headers.="Reply-To: ".$yourname." <".$youremail.">\n"; $headers.="MIME-Version: 1.0\n"; $headers.="Content-Type: multipart/mixed; boundary=\"".$boundary."\"\n"; $headers.="X-Sender: ".$_SERVER['REMOTE_ADDR']."\n"; $headers.="X-Mailer: PHP/".phpversion()."\n"; $headers.="X-Priority: ".$priority."\n"; $headers.="Return-Path: <".$youremail.">\n"; $headers.="This is a multi-part message in MIME format.\n"; Quote Link to comment https://forums.phpfreaks.com/topic/119464-question-about-simple-mailer-script/#findComment-615398 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.