lena_k198 Posted October 2, 2009 Share Posted October 2, 2009 Hi all, I created a form on the web and would like set up an automatic response to be sent to any user who submits the form. The response is generic i.e. the exact same for everyone. The code below is working, I need auto response message. Please help: <?php if (array_key_exists('button',$_POST)) { $post = $_POST; $name = $_POST['name']; $email = $_POST['email']; $comments = $_POST['message']; $expected = array('name', 'email', 'message'); $required = array('name', 'email', 'message'); $missing = array(); foreach ($_POST as $key => $value) { $temp = is_array($value) ? $value : trim($value); if (empty($temp) && in_array($key, $required)) { array_push($missing, $key); } elseif (in_array($key, $expected)) { ${$key} = $temp; } } if (!empty($email)) { $checkEmail = '/^[^@]+@[^\s\r\n\'";,@%]+$/'; if (!preg_match($checkEmail, $email)){ array_push($missing, 'email'); } } if (empty($missing)){ $to = '[email protected] ';//put your email here $subject = $name; // you can put what ever subject you want here $message = "Name: $name\n\n"; $message .= "Comments: $comments"; $message = wordwrap($message, 70); $additionalHeaders = "From: $email"; if (!empty($email)) { $additionalHeaders .= "\r\nReply-To: $email"; } $mailSent = mail($to, $subject, $message, $additionalHeaders); if (empty($missing)){ } elseif (empty($missing)){ $mailSent = true; } if ($mailsent = true){ unset($missing); unset($post); } } } ?> Link to comment https://forums.phpfreaks.com/topic/176241-automatic-email-response-in-php-form/ Share on other sites More sharing options...
Jnerocorp Posted October 2, 2009 Share Posted October 2, 2009 I can help you with this just give me a minute Link to comment https://forums.phpfreaks.com/topic/176241-automatic-email-response-in-php-form/#findComment-928787 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.