Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // load the variables form address bar
- $EmailTo = "elloh7@gmail.com";
- $IP = $_SERVER['REMOTE_ADDR'];
- $Name = trim(stripslashes($_POST['Name']));
- $Email = trim(stripslashes($_POST['Email']));
- $Message = trim(stripslashes($_POST['Message']));
- $Captcha = trim(stripslashes($_POST['Captcha']));
- $Subject = "Message from ".$Name;
- // captcha validation
- if(md5($Captcha).'a4xn' == $_COOKIE['tntcon']){
- require_once "Mail.php";
- $host = "mail.example.com";
- $username = "smtp_username";
- $password = "smtp_password";
- $from = "Web Form Bot <ContactForm@sudopic.com>";//you could make this be the persons name and e-mail from the form fields if you wanted
- // if validation was correct, send mail
- // email body
- $Body .= "IP: ";
- $Body .= $IP;
- $Body .= "\n";
- $Body .= "Name: ";
- $Body .= $Name;
- $Body .= "\n";
- $Body .= "From: ";
- $Body .= $Email;
- $Body .= "\n";
- $Body .= "\n";
- $Body .= "\n";
- $Body .= $Message;
- $headers = array ('From' => $from,
- 'To' => $EmailTo,
- 'Subject' => $subject);
- $smtp = Mail::factory('smtp',
- array ('host' => $host,
- 'auth' => true,
- 'username' => $username,
- 'password' => $password));
- $mail = $smtp->send($to, $headers, $Body);
- //mail($EmailTo, $Subject, $Body, "From: $Email"); //commented out old mail function
- // delete the cookie so it cannot sent again by refreshing this page
- setcookie('tntcon','');
- } else {
- // if verification code was incorrect then display error page
- print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
- exit;
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement