JCC Express

Mail

Introduction

JCC Express MVC provides a Laravel-style mail API with:

  • Mail facade (jcc-express-mvc/lib/Mail)
  • Mailable base class
  • Envelope, Address, Content, and Attachment
  • Driver manager (Nodemailer or Resend, based on MAIL_DRIVER)

Quick send with Mail

TypeScript

Mail.to(...).cc(...).bcc(...).send(...) builds a payload and routes it through MailManager.


Sending a Mailable class

Use Mailable for reusable templates and metadata:

TypeScript

Send it:

TypeScript

Attachments

The Attachment helper supports path, storage, and in-memory data:

TypeScript

Driver selection

MailManager chooses the driver from MAIL_DRIVER:

  • resend -> Resend driver
  • anything else (smtp, mailtrap, etc.) -> Nodemailer driver

Related env values used by drivers include:

  • MAIL_DRIVER
  • MAIL_HOST, MAIL_PORT, MAIL_USERNAME, MAIL_PASSWORD
  • MAIL_FROM_ADDRESS, MAIL_FROM_NAME
  • RESEND_API_KEY (or MAIL_API_KEY fallback)

Rendering behavior

  • If content is Content, it compiles with its view and with data.
  • If content is a string, it is treated as a view/template path and compiled.
  • subject, recipients, cc/bcc, and attachments are then passed to the active driver.

Summary

  • Use Mail.to(...).send(...) for simple emails.
  • Use Mailable + Envelope + Content for reusable classes.
  • Use Attachment for files/data payloads.
  • Driver is selected automatically by MAIL_DRIVER.