<?php
use PHPMailer\PHPMailer\PHPMailer;

require_once dirname(__DIR__, 2) . '/web/lib/PHPMailer/src/Exception.php';
require_once dirname(__DIR__, 2) . '/web/lib/PHPMailer/src/PHPMailer.php';
require_once dirname(__DIR__, 2) . '/web/lib/PHPMailer/src/SMTP.php';

/**
 * Devuelve un PHPMailer listo para enviar, configurado con el SMTP del proyecto.
 */
function crearMailer(): PHPMailer
{
    $m = new PHPMailer(true);
    $m->isSMTP();
    $m->Host       = 'ogjrosario.com.ar';
    $m->SMTPAuth   = true;
    $m->Username   = 'administrador@ogjrosario.com.ar';
    $m->Password   = 'aLu6S6LStvnYysX';
    $m->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; // SSL puerto 465
    $m->Port       = 465;
    $m->SMTPOptions = [
        'ssl' => [
            'verify_peer'       => false,
            'verify_peer_name'  => false,
            'allow_self_signed' => true,
        ],
    ];
    $m->CharSet = 'UTF-8';
    $m->setFrom('administrador@ogjrosario.com.ar', 'Agenda Juicios OGJ Rosario');
    $m->setLanguage('es');
    return $m;
}
