<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;

require __DIR__ . '/../vendor/autoload.php';

function getMailer() {
    $mail = new PHPMailer(true);

    try {
        // Configuración del servidor de correos
        $mail->isSMTP();
        $mail->Host       = 'smtp-relay.brevo.com';
        $mail->SMTPAuth   = true;
        $mail->Username   = '8fcde0001@smtp-brevo.com';
        $mail->Password   = 'WJckTKnPgENtSzqd';
        $mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
        $mail->Port       = 587;

        $mail->setFrom('diplomaster.sender@gmail.com', 'LANIA: Diplomas');

        return $mail;
    } catch (Exception $e) {
        error_log("Mailer Error: {$e->getMessage()}");
        return null;
    }
}
