<?php
declare(strict_types=1);

namespace App\Services;

final class Mailer
{
    public static function send(string $to, string $subject, string $body): bool
    {
        $config = require __DIR__ . '/../../config/mail.php';

        if (empty($config['enabled'])) {
            return false;
        }

        $headers = [];
        $headers[] = 'MIME-Version: 1.0';
        $headers[] = 'Content-type: text/plain; charset=UTF-8';
        $headers[] = 'From: ' . ($config['from_name'] ?? 'Open Conference Portal') . ' <' . ($config['from_email'] ?? 'no-reply@easychair.local') . '>';

        return @mail($to, $subject, $body, implode("\r\n", $headers));
    }
}
