true, 'message' => 'Mensaje recibido (spam bloqueado)']); exit; } // Validar campos requeridos $required_fields = ['nombre', 'email', 'division', 'mensaje']; foreach ($required_fields as $field) { if (empty($_POST[$field])) { echo json_encode(['success' => false, 'message' => 'Por favor, completá todos los campos obligatorios.']); exit; } } // Validar formato de email if (!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) { echo json_encode(['success' => false, 'message' => 'El email ingresado no es válido.']); exit; } // Validar reCAPTCHA if (empty($_POST['g-recaptcha-response'])) { echo json_encode(['success' => false, 'message' => 'Por favor, completa el reCAPTCHA.']); exit; } // Verificar reCAPTCHA con Google $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'; $recaptcha_data = [ 'secret' => $RECAPTCHA_SECRET_KEY, 'response' => $_POST['g-recaptcha-response'], 'remoteip' => $_SERVER['REMOTE_ADDR'] ]; $recaptcha_options = [ 'http' => [ 'method' => 'POST', 'content' => http_build_query($recaptcha_data) ] ]; $recaptcha_context = stream_context_create($recaptcha_options); $recaptcha_result = file_get_contents($recaptcha_url, false, $recaptcha_context); $recaptcha_json = json_decode($recaptcha_result, true); if (!$recaptcha_json['success']) { echo json_encode(['success' => false, 'message' => 'Error de verificación reCAPTCHA. Por favor, intentá de nuevo.']); exit; } // ============================================ // PREPARAR Y ENVIAR EL EMAIL // ============================================ // Sanitizar datos $nombre = htmlspecialchars(strip_tags($_POST['nombre'])); $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL); $empresa = isset($_POST['empresa']) ? htmlspecialchars(strip_tags($_POST['empresa'])) : 'No especificada'; $telefono = isset($_POST['telefono']) ? htmlspecialchars(strip_tags($_POST['telefono'])) : 'No especificado'; $division = htmlspecialchars(strip_tags($_POST['division'])); $tipo = isset($_POST['tipo']) && !empty($_POST['tipo']) ? htmlspecialchars(strip_tags($_POST['tipo'])) : 'No especificado'; $mensaje = htmlspecialchars(strip_tags($_POST['mensaje'])); $referencia = isset($_POST['referencia']) && !empty($_POST['referencia']) ? htmlspecialchars(strip_tags($_POST['referencia'])) : 'No especificado'; // Construir el cuerpo del email $email_subject = "Nuevo contacto desde VettaIO - $nombre"; $email_body = " Nuevo mensaje de contacto

Nuevo mensaje de contacto

VettaIO - Transformamos desafíos tecnológicos

👤 Nombre:
$nombre
📧 Email:
$email
🏢 Empresa:
$empresa
📞 Teléfono:
$telefono
🎯 División de interés:
$division
📋 Tipo de consulta:
$tipo
💬 Mensaje:
$mensaje
🔍 ¿Cómo nos encontraste?
$referencia
"; // Cabeceras del email $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=UTF-8\r\n"; $headers .= "From: $email\r\n"; $headers .= "Reply-To: $email\r\n"; $headers .= "X-Mailer: PHP/" . phpversion(); // Enviar email $mail_sent = mail($DESTINATION_EMAIL, $email_subject, $email_body, $headers); if ($mail_sent) { echo json_encode(['success' => true, 'message' => '¡Mensaje enviado con éxito! Te responderemos en menos de 24 horas.']); } else { echo json_encode(['success' => false, 'message' => 'Error al enviar el mensaje. Por favor, intentá de nuevo o escribinos directamente a info@vettaio.com.']); } ?>