i use have email form using php. seems stopped working , can't find working script. claims email got sent never receive it.
i've tried both yahoo , gmail accounts accounts on server. maybe there wrong code? feel it's not making sense there doesn't seem solution anywhere.
thank you.
<?php if(isset($_post['email'])) { $email_to = "somemail@someserver.com"; $email_subject = "your email subject line"; function died($error) { echo "we sorry, there error(s) found form submitted. "; echo "these errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "please go , fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_post['first_name']) || !isset($_post['last_name']) || !isset($_post['email']) || !isset($_post['telephone']) || !isset($_post['comments'])) { died('we sorry, there appears problem form submitted.'); } $first_name = $_post['first_name']; $last_name = $_post['last_name']; $email_from = $_post['email']; $comments = $_post['comments']; $error_message = ""; $email_exp = '/^[a-za-z0-9._%-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'the email address entered not appear valid.<br />'; } $string_exp = "/^[a-za-z .'-]+$/"; if(!preg_match($string_exp,$first_name)) { $error_message .= 'the first name entered not appear valid.<br />'; } if(!preg_match($string_exp,$last_name)) { $error_message .= 'the last name entered not appear valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'the comments entered not appear valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "first name: ".clean_string($first_name)."\n"; $email_message .= "last name: ".clean_string($last_name)."\n"; $email_message .= "email: ".clean_string($email_from)."\n"; $email_message .= "comments: ".clean_string($comments)."\n"; $headers = 'from: '.$email_from."\r\n". 'reply-to: '.$email_from."\r\n" . 'x-mailer: php/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> thank contacting us. in touch soon. <?php } ?>
Comments
Post a Comment