Advertisement
ryojinma

mailer.php

Apr 4th, 2015
606
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?PHP
  2. $to = "YOUR EMAIL";
  3. $subject = "Contact Page";
  4. $headers = "From: Contact Page";
  5. $forward = 0;
  6. $location = "";
  7. $date = date ("l, F jS, Y");
  8. $time = date ("h:i A");
  9. $msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";
  10. $email;$comment;$captcha;
  11. if(isset($_POST['email'])){
  12. $email=$_POST['email'];
  13. }if(isset($_POST['comment'])){
  14. $email=$_POST['comment'];
  15. }if(isset($_POST['g-recaptcha-response'])){
  16. $captcha=$_POST['g-recaptcha-response'];
  17. }
  18. if(!$captcha){
  19. echo '<h2>Please check the the captcha form.</h2>';
  20. exit;
  21. }
  22.  
  23. if ($_SERVER['REQUEST_METHOD'] == "POST") {
  24. foreach ($_POST as $key => $value) {
  25. $msg .= ucfirst ($key) ." : ". $value . "\n";
  26. }
  27. }
  28. else {
  29. foreach ($_GET as $key => $value) {
  30. $msg .= ucfirst ($key) ." : ". $value . "\n";
  31. }
  32. }
  33. mail($to, $subject, $msg, $headers);
  34. if ($forward == 1) {
  35. header ("Location:$location");
  36. }
  37. else {
  38. include("index.html");
  39. }
  40. $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=KEYFROM GOOGLE&response=".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']);
  41. if($response.success==false)
  42. {
  43. echo '<h2>You are spammer ! Get the @$%K out</h2>';
  44. }else
  45. {
  46. echo '<h2>Thanks for posting comment.</h2>';
  47. }
  48. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement