Mailing

Mailing

Keel mail delivery is handled by the Mailer class and supports two drivers: smtp and log.

Environment settings

# smtp | log
MAIL_MAILER=smtp

MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS=hello@example.com
MAIL_FROM_NAME="Keel App"

Use MAIL_MAILER=log for local development without SMTP credentials.

Driver behavior

  • smtp: sends real email through PHPMailer over SMTP.
  • log: appends outgoing messages to storage/logs/mail.log.
  • unsupported MAIL_MAILER value: returns false and writes an error log message.

How to call the mailer

use Keel\Core\Mailer;

$sent = Mailer::send(
    $toEmail,
    $toName,
    'Subject line',
    '<p>HTML body</p>'
);

Mailer::send returns true on success and false on failure.

Where it is used today

  • OTP and magic-link sign-in emails use Mailer::send directly via OtpService and MagicLinkService.
  • Organization invite emails are queued, then sent by SendOrganizationInviteJob through Mailer::send.

Local testing flow

  1. Set MAIL_MAILER=log in .env.
  2. Request an OTP or magic link from the login page.
  3. Open storage/logs/mail.log and copy the code or URL from the newest entry.