Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <html lang="es">
  2. <head>
  3. <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
  4. </head>
  5. <body>
  6. <?php
  7. use PHPMailer\PHPMailer\PHPMailer;
  8. require 'vendor/autoload.php';
  9.  
  10. $name    = strip_tags($_POST["nombre"]);
  11. $apellidos = strip_tags($_POST["apellidos"]);
  12. $email      = strip_tags($_POST["correo"]);
  13. $phone      = strip_tags($_POST["telefono"]);
  14. $mensaje   = strip_tags($_POST["comentario"]);
  15. $fecha        = time();
  16. $fechaFormato = date("j/n/Y", $fecha);
  17.  
  18.     $mail = new PHPMailer;
  19.     $mail->isSMTP();
  20.     $mail->Host = 'mx1.hostinger.com';
  21.     $mail->Port = 587;
  22.     $mail->SMTPAuth = true;
  23.     $mail->Username = 'admin@pokefarrago.com';
  24.     $mail->Password = '123456';
  25.     $mail->setFrom('admin@pokefarrago.com', 'Formulario Contacto');
  26.     $mail->addAddress('admin@pokefarrago.com', 'Nombre del destinatario');
  27.     if ($mail->addReplyTo($_POST['email'], $_POST['name'], $_POST['apellidos'], $_POST['fechaFormato'])) {
  28.         $mail->Subject = 'PHPMailer contact form';
  29.         $mail->isHTML(false);
  30.         $mail->Body = <<<EOT
  31. Email: {$_POST['email']}
  32. Name: {$_POST['name']}
  33. Apellidos: {$_POST['apellidos']}
  34. Phone: {$_POST['phone']}
  35. Date: {$_POST['fechaFormato']}
  36. Message: {$_POST['mensaje']}
  37. EOT;
  38.        
  39. require_once "Mailer/recaptchalib.php";
  40. $siteKey = "6LdzoaoUAAAAANtOKJdROeAFvOsrko0ZhGAGPG0K";
  41. $secret  = "6LdzoaoUAAAAAJf2JgobUjQUpYqv193Rp0vxwJ05";
  42. $lang = "en";
  43. $resp = null;
  44. $error = null;
  45. $reCaptcha = new ReCaptcha($secret);
  46. if ($_POST["g-recaptcha-response"]) {
  47.     $resp = $reCaptcha->verifyResponse(
  48.         $_SERVER["REMOTE_ADDR"],
  49.         $_POST["g-recaptcha-response"]
  50.     );
  51.    if (!$mail->send()) {
  52.             $msg = 'Sorry, something went wrong. Please try again later.';
  53.         } else {
  54.             $msg = 'Message sent! Thanks for contacting us.';
  55.         }
  56.     } else {
  57.         $msg = 'Invalid email address, message ignored.';
  58.     }
  59. } else {
  60.     echo "Porfavor Complete el reCaptcha";
  61. }
  62. ?>
  63. </body>
  64. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement