Advertisement
Guest User

Untitled

a guest
May 12th, 2017
534
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.56 KB | None | 0 0
  1. <?php
  2. // load the variables form address bar
  3. $EmailTo = "elloh7@gmail.com";
  4. $IP = $_SERVER['REMOTE_ADDR'];
  5. $Name = trim(stripslashes($_POST['Name']));
  6. $Email = trim(stripslashes($_POST['Email']));
  7. $Message = trim(stripslashes($_POST['Message']));
  8. $Captcha = trim(stripslashes($_POST['Captcha']));
  9. $Subject = "Message from ".$Name;
  10.  
  11. // captcha validation
  12. if(md5($Captcha).'a4xn' == $_COOKIE['tntcon']){
  13. require_once "Mail.php";
  14.     $host = "mail.example.com";
  15.     $username = "smtp_username";
  16.     $password = "smtp_password";
  17.     $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
  18.     // if validation was correct, send mail
  19.    
  20.     // email body
  21.     $Body .= "IP: ";
  22.     $Body .= $IP;
  23.     $Body .= "\n";
  24.    
  25.     $Body .= "Name: ";
  26.     $Body .= $Name;
  27.     $Body .= "\n";
  28.    
  29.     $Body .= "From: ";
  30.     $Body .= $Email;
  31.    
  32.     $Body .= "\n";
  33.     $Body .= "\n";
  34.     $Body .= "\n";
  35.     $Body .= $Message;
  36.  
  37.  
  38.     $headers = array ('From' => $from,
  39.       'To' => $EmailTo,
  40.       'Subject' => $subject);
  41.  
  42.     $smtp = Mail::factory('smtp',
  43.       array ('host' => $host,
  44.         'auth' => true,
  45.         'username' => $username,
  46.         'password' => $password));
  47.  
  48.  
  49.  
  50. $mail = $smtp->send($to, $headers, $Body);
  51.  
  52. //mail($EmailTo, $Subject, $Body, "From: $Email"); //commented out old mail function
  53.  
  54.     // delete the cookie so it cannot sent again by refreshing this page
  55.     setcookie('tntcon','');
  56. } else {
  57.     // if verification code was incorrect then display error page
  58.     print "<meta http-equiv=\"refresh\" content=\"0;URL=error.html\">";
  59.     exit;
  60. }
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement