<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
if ($_POST['g-recaptcha-response'] == '') {
$url2= "nocatpcha.html";
echo '<META HTTP-EQUIV=REFRESH CONTENT="1; '.$url2.'">';
} else {
$obj = new stdClass();
$obj->secret = "6LdejEIdAAAAAIl8C7X6SQtep5P446-DQqtDoo8Z";
$obj->response = $_POST['g-recaptcha-response'];
$obj->remoteip = $_SERVER['REMOTE_ADDR'];
$url = 'https://www.google.com/recaptcha/api/siteverify';
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($obj)
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
$validar = json_decode($result);
/* FIN DE CAPTCHA */
if ($validar->success) {
$lname = $_POST ['lname'];
$contactEmail = $_POST ['contactEmail'];
$pais = $_POST ['pais'];
$mobileNumber = $_POST ['mobileNumber'];
$comment = $_POST ['comment'];
$body = "La siguiente persona desea ser contactada: ".$lname."<br>Su correo electrónico es: ".$contactEmail."<br>Reside en: ".$pais."<br>Su telefono es: ".$mobileNumber."<br>Su mensaje es: ".$comment;
$remitente = "Cliente: ".$lname;
require 'PHPMailer/Exception.php';
require 'PHPMailer/PHPMailer.php';
require 'PHPMailer/SMTP.php';
$mail = new PHPMailer(true);
try {
//Server settings
$mail->SMTPDebug = 0; //Enable verbose debug output
$mail->isSMTP(); //Send using SMTP
$mail->Host = 'smtp.startlogic.com'; //Set the SMTP server to send through
$mail->SMTPAuth = true; //Enable SMTP authentication
$mail->Username = 'ventas@alkkon.com'; //SMTP username
$mail->Password = 'Alkkon15'; //SMTP password
$mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption
$mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS`
//Recipients
$mail->setFrom('ventas@alkkon.com', $remitente);
$mail->addAddress('ventas@alkkon.com', 'DepV'); //Add a recipient
//Content
$mail->isHTML(true); //Set email format to HTML
$mail->Subject = 'Nuevo formulario de Landing MDVR';
$mail->Body = $body;
$mail->send();
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
$url= "gracias.html";
echo '<META HTTP-EQUIV=REFRESH CONTENT="1; '.$url.'">';
} else {
$url2= "nocatpcha.html";
echo '<META HTTP-EQUIV=REFRESH CONTENT="1; '.$url2.'">';
}
}
?>