= 5.2.0 # # copyright 2005-2008 by Charles Reace # # This software available as open source software under the Gnu General Public # License: http://www.gnu.org/licenses/gpl.html # ############################################################################### ############################################################################### # user-defined variables - update for your email address(es) ############################################################################### session_cache_limiter('nocache'); session_start(); # link to "thank you" page: $thanks = "http://www.example.com/thanks.php"; # Modify the following variable to specify where emails will be sent. $to = "name@example.com"; # uncomment and edit the next line if you want to cc someone: # $cc = "name@example.com"; # uncomment and edit the next line if you want to bcc someone: # $bcc = "name@example.com"; ################################# # end of user-defined variables # ################################# # Init. some variables: $error = ""; $success = false; # process form if submitted: if(isset($_POST['submit'])) { foreach($_POST as $key => $val) { if(empty($_POST[$key]) and $key != 'id') { $error .= "You must enter a value for " . ucwords(str_replace("_", " ", $key)) . ". "; } else { if(get_magic_quotes_gpc()) { $_POST[$key] = stripslashes($val); } } if($key != 'message') { $_POST[$key] = preg_replace('/[\r\n]/', ' ', $val); } } if($_POST['email_address'] != $_POST['repeat_email']) { $error .= "Email Address is not the same as Repeat Email. "; } elseif(filter_var($_POST['email_address'], FILTER_VALIDATE_EMAIL) == false OR filter_var($_POST['email_address'], FILTER_SANITIZE_EMAIL !== $_POST['email_address'])) { // added 'SANITIZE' to deal with 'FILTER' bug when last character is newline $error .= "'{$_POST['email_address']}' does not appear to be a valid email address. "; } if($_POST['id'] !== '') { $error .= ' Invalid form data received.'; } if($_POST['token'] != $_SESSION['token']) { user_error("Post '".$_POST['token']."' != '".$_SESSION['token']."'"); $error .= ' Spam robot check failed. Make sure cookies are enabled for this site, or this form will not work.'; } unset($_SESSION['token']); if(empty($error)) # no errors in input, so go ahead and email it. { $headers = "From: " . preg_replace('/[\r\n]+/', ' ', $_POST['email_address']); if(!empty($cc)) { $headers .= "\r\nCc: $cc"; } if(!empty($bcc)) { $headers .= "\r\nBcc: $bcc"; } $headers .= "\r\nX-Mailer: PHP/" . phpversion(); $msg = "From {$_POST['name']} ({$_POST['email_address']})"; $msg .= "\n\n\n{$_POST['message']}"; $result = @mail($to, $_POST['subject'], $msg, $headers); if(!$result) { $error = "There was an unknown error while attempting to send your email."; } else { header("Location: $thanks"); } } } ?> Email Me $error

\n"; } ?>

Email Me

' method=post>
Your Contact Information

Do not enter anything in this field:

>

>

>

Message

>