1ra Versión

This commit is contained in:
MarcosFlorSalcedo
2026-07-14 18:24:27 -03:00
commit 8ec55e40fc
86 changed files with 15839 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
<?php
/**
* Configuración de Brevo SMTP
* Este archivo contiene las credenciales para enviar emails vía Brevo
*/
// Credenciales de Brevo
define('BREVO_API_KEY', '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');
define('BREVO_API_URL', 'https://api.brevo.com/v3/smtp/email');
define('BREVO_FROM_EMAIL', 'lumicaela2.987@gmail.com');
define('BREVO_FROM_NAME', 'Complejo Cap1tan');
/**
* Función para enviar emails usando API REST de Brevo
* Esta es más confiable que SMTP directo
*/
function enviarEmailBrevo($para, $asunto, $mensaje, $esHTML = false) {
try {
// Preparar el payload
$payload = [
'sender' => [
'name' => BREVO_FROM_NAME,
'email' => BREVO_FROM_EMAIL
],
'to' => [
[
'email' => $para,
'name' => $para
]
],
'subject' => $asunto,
'htmlContent' => $esHTML ? $mensaje : nl2br(htmlspecialchars($mensaje)),
'textContent' => $mensaje
];
// Preparar headers
$headers = [
'Content-Type: application/json',
'api-key: ' . BREVO_API_KEY,
'Accept: application/json'
];
// Inicializar cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, BREVO_API_URL);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Ejecutar
$respuesta = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
// Verificar respuesta
if ($error) {
error_log('Brevo API Error: ' . $error);
return false;
}
if ($http_code >= 200 && $http_code < 300) {
error_log('Email enviado exitosamente a ' . $para);
return true;
} else {
error_log('Brevo API HTTP ' . $http_code . ': ' . $respuesta);
return false;
}
} catch (Exception $e) {
error_log('Brevo Exception: ' . $e->getMessage());
return false;
}
}
/**
* Función fallback usando mail() nativa
*/
function enviarEmailFallback($para, $asunto, $mensaje) {
$headers = "From: " . BREVO_FROM_NAME . " <" . BREVO_FROM_EMAIL . ">\r\n";
$headers .= "Reply-To: " . BREVO_FROM_EMAIL . "\r\n";
$headers .= "Content-Type: text/plain; charset=UTF-8\r\n";
return @mail($para, $asunto, $mensaje, $headers);
}
?>