Framework Docs Mailer

Mailer

The Mailer class is a thin wrapper around PHPMailer that autoconfigures SMTP or Sendmail from the framework's Core settings. Call Mailer::make() to get a pre-configured PHPMailer instance, then use the full PHPMailer API to compose and send.

Namespace: Wojo\Core\Mailer (final class)

API

Method Signature Description
make() static make(): PHPMailer Return a configured PHPMailer instance. Sets charset, SMTP/Sendmail, from-address from Core settings.
sendMail() static sendMail(): PHPMailer Alias for make() — choose whichever reads better in context.
send() static send(PHPMailer $mail): bool Call $mail->send(), catch exceptions, log to Debug, and return success boolean.

Configuration

SMTP settings are read from the Core object (populated from database settings, not config files directly):

Setting Description
mailer 'SMTP' or 'SENDMAIL'
smtp_host SMTP server hostname
smtp_port Port (25, 465, or 587)
smtp_user / smtp_pass SMTP credentials
smtp_secure 'ssl', 'tls', or auto-detected from port
site_email Default From address

Example

PHP
use PHPMailer\PHPMailer\Exception;
use Wojo\Core\Mailer;

try {
    $mail = Mailer::make();

    $mail->addAddress('user@example.com', 'Jane Doe');
    $mail->Subject = 'Welcome to the App';
    $mail->isHTML(true);
    $mail->Body    = '<h1>Welcome!</h1><p>Your account is ready.</p>';
    $mail->AltBody = 'Welcome! Your account is ready.';

    $sent = Mailer::send($mail);

    if ($sent) {
        Response::success('Email sent.');
    } else {
        Response::error('Failed to send email.');
    }
} catch (Exception $e) {
    Response::error($e->getMessage(), 500);
}