<?php//check to make sure the user didn't input bogus data$errors = NULL;foreach($_POST as $key => $value) { if(!preg_match('/.+/', $value)) { $errors .= "You neglected to enter a value for field {$key}\n<br />"; }}if(preg_match('/[a-zA-Z]/', $_POST['phone'])) { $errors .= "The phone number you entered contained a letter.\n<br />";}if(!preg_match('/^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+([a-z]{2}|aero|arpa|biz|com|coop|edu|gov|info|int|jobs|mil|museum|name|nato|net|org|pro|travel)$/', $_POST['email'])) { $errors .= "You entered an invalid email address.\n<br />";}//after all your user error checking is done do thisif(isset($errors)) { echo $errors; die();} else { $to = "foo@bar.com"; $subject = "subject here"; $message = "Name: {$_POST['name']}Address: {$_POST['address']}Phone: {$_POST['phone']}Email {$_POST['email']}KTHXBAI!"; $message = str_replace("\n.", "\n..", $message); $message = wordwrap($message, 70); if(mail($to,$subject,$message)) { echo "Successfully sent email\n"; } else { echo "Unable to send an email.\n"; }}?>