Guest User

AJAX_MAIL.PHP

a guest
Nov 11th, 2014
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.59 KB | None | 0 0
  1. AJAX_MAIL.PHP
  2.  
  3. <?php
  4. require_once('recaptchalib.php');
  5. require('../../../../wp-blog-header.php');
  6. global $qode_options_proya;
  7.  
  8. $publickey = $qode_options_proya['recaptcha_public_key'];
  9. $privatekey = $qode_options_proya['recaptcha_private_key'];
  10.  
  11. if ($publickey == "") $publickey = "6Ld5VOASAAAAABUGCt9ZaNuw3IF-BjUFLujP6C8L";
  12. if ($privatekey == "") $privatekey = "6Ld5VOASAAAAAKQdKVcxZ321VM6lkhBsoT6lXe9Z";
  13.  
  14. $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
  15. $quest = $_POST["question"];
  16.  
  17. $use_captcha = $qode_options_proya['use_recaptcha'];
  18. if ($resp->is_valid || $use_captcha == "no") {
  19.     ?>success<?php
  20.  
  21.     $email_to = $qode_options_proya['native_mail'];
  22.  
  23.     $email_from = $qode_options_proya['email_from'];
  24.     $subject = $qode_options_proya['email_subject'];
  25.  
  26.     $text = "Name: " . $_POST["name"] . " " . $_POST["lastname"] . "\n";
  27.     $text = "Question: " . $_POST["question"] . "\n";
  28.     $text .= "Email: " . $_POST["email"] . "\n";
  29.     $text .= "WebSite: " . $_POST["website"] . "\n";
  30.     $text .= "Message: " . $_POST["message"];
  31.  
  32.     $headers = "MIME-Version: 1.0" . "\r\n";
  33.     $headers .= "Content-type:text/plain; charset=utf-8" . "\r\n";
  34.     $headers .= "From: '".$_POST['name']." ".$_POST['lastname']."' <".$email_from."> " . "\r\n";
  35.    
  36.     $result = wp_mail($email_to, $subject, $text, $headers);
  37.    
  38.  
  39.     if(!$result) {
  40.         global $phpmailer;
  41.         var_dump($phpmailer->ErrorInfo);
  42.     }
  43. }
  44. else {
  45.     die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .  "(reCAPTCHA said: " . $resp->error . ")");
  46. }
  47. ?>
Advertisement
Add Comment
Please, Sign In to add comment