Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html lang="es">
- <head>
- <script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
- </head>
- <body>
- <?php
- use PHPMailer\PHPMailer\PHPMailer;
- require 'vendor/autoload.php';
- $name = strip_tags($_POST["nombre"]);
- $apellidos = strip_tags($_POST["apellidos"]);
- $email = strip_tags($_POST["correo"]);
- $phone = strip_tags($_POST["telefono"]);
- $mensaje = strip_tags($_POST["comentario"]);
- $fecha = time();
- $fechaFormato = date("j/n/Y", $fecha);
- $mail = new PHPMailer;
- $mail->isSMTP();
- $mail->Host = 'mx1.hostinger.com';
- $mail->Port = 587;
- $mail->SMTPAuth = true;
- $mail->Username = 'admin@pokefarrago.com';
- $mail->Password = '123456';
- $mail->setFrom('admin@pokefarrago.com', 'Formulario Contacto');
- $mail->addAddress('admin@pokefarrago.com', 'Nombre del destinatario');
- if ($mail->addReplyTo($_POST['email'], $_POST['name'], $_POST['apellidos'], $_POST['fechaFormato'])) {
- $mail->Subject = 'PHPMailer contact form';
- $mail->isHTML(false);
- $mail->Body = <<<EOT
- Email: {$_POST['email']}
- Name: {$_POST['name']}
- Apellidos: {$_POST['apellidos']}
- Phone: {$_POST['phone']}
- Date: {$_POST['fechaFormato']}
- Message: {$_POST['mensaje']}
- EOT;
- require_once "Mailer/recaptchalib.php";
- $siteKey = "6LdzoaoUAAAAANtOKJdROeAFvOsrko0ZhGAGPG0K";
- $secret = "6LdzoaoUAAAAAJf2JgobUjQUpYqv193Rp0vxwJ05";
- $lang = "en";
- $resp = null;
- $error = null;
- $reCaptcha = new ReCaptcha($secret);
- if ($_POST["g-recaptcha-response"]) {
- $resp = $reCaptcha->verifyResponse(
- $_SERVER["REMOTE_ADDR"],
- $_POST["g-recaptcha-response"]
- );
- if (!$mail->send()) {
- $msg = 'Sorry, something went wrong. Please try again later.';
- } else {
- $msg = 'Message sent! Thanks for contacting us.';
- }
- } else {
- $msg = 'Invalid email address, message ignored.';
- }
- } else {
- echo "Porfavor Complete el reCaptcha";
- }
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement