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."; } ?> 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"; 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
Archived
This topic is now archived and is closed to further replies.