ski6 Posted November 12, 2009 Share Posted November 12, 2009 Hi Guys, can some one please help me create an auto reply message to user who fills in my form. I also please need help with this aswell. When i recieved the inquiry in my inbox(outlook 2007) it shows that it was sent from some server thing. How do i make it that it will show the user's address that just filled in the form so that when i click reply it will reply to the user's email adress <?php /* Set e-mail recipient */ $myemail = "[email protected]"; /* Check all form inputs using check_input function */ $yourname = check_input($_POST['yourname'], "Enter your Full name"); $subject = check_input($_POST['subject'], "Write a subject"); $email = check_input($_POST['email']); $number = check_input($_POST['number'], "Enter a contact number"); $region = check_input($_POST['region']); $query = check_input($_POST['query'], "Write a query"); /* If e-mail is not valid show error message */ if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email)) { show_error("E-mail address not valid"); } /* Let's prepare the message for the e-mail */ $message = " Hello) Your contact form has been submitted by: Name: $yourname Subject: $subject Email: $email Conact Number: $number Region: $region Query: $query End of message "; /* Send the message using mail() function */ mail($myemail, $subject, $message); /* Redirect visitor to the thank you page */ header('Location: thanks.htm'); exit(); /* Functions we used */ function check_input($data, $problem='') { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); if ($problem && strlen($data) == 0) { show_error($problem); } return $data; } function show_error($myError) { ?> <html> <body> <b>Please correct the following error:</b><br /> <?php echo $myError; ?> </body> </html> <?php exit(); } ?> Link to comment https://forums.phpfreaks.com/topic/181267-auto-reply-help-and-other/ Share on other sites More sharing options...
cags Posted November 12, 2009 Share Posted November 12, 2009 You will need to use the 4th parameter of mail, the headers parameter. To show it as from the person you would use something like... $headers = "From: $email\r\n"; ... but that isn't really the correct behavior and could cause it to end up in your junk/spam folder. Personally I would recommend... $headers = "Reply-To: $email\r\n"; $headers .= "Return-Path: $email\r\n"; ... that way it will show the e-mail as being from your server, but if you click reply it should send it to the users e-mail. Link to comment https://forums.phpfreaks.com/topic/181267-auto-reply-help-and-other/#findComment-956277 Share on other sites More sharing options...
ski6 Posted November 13, 2009 Author Share Posted November 13, 2009 Hi Cages please advise me where to add this coding. Can you please help with an auto reply with as well. All i need it to say is, Thank you, your should get a reply within 48 hours. Please advise where i should add this as well Thanks Link to comment https://forums.phpfreaks.com/topic/181267-auto-reply-help-and-other/#findComment-956669 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.