sendemail Architecture

sendemail Architecture An architecture diagram generated by Archify. Caller · CLI or library caller · Architecture component Caller CLI or library caller CLI Entry & Parser · Commander.js program · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) CLI Entry & Parser Commander.js program CLI Command Handlers · text / html subcommands · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) CLI Command Handlers text / html subcommands HTML Builder · EJS render + sanitize · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) HTML Builder EJS render + sanitize send() Orchestrator · public API entry point · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) send() Orchestrator public API entry point EmailSender · extends EmailTransport · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) EmailSender extends EmailTransport SchemaValidator · generic Zod wrapper · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) SchemaValidator generic Zod wrapper EmailTransport · OAuth2 SMTP setup · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) EmailTransport OAuth2 SMTP setup Config & Env Loader · .env / process.env · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) › Local secrets: .env / process.env (host-owned) Config & Env Loader .env / process.env Nodemailer Transporter · SMTP client (OAuth2) · Consuming Node.js process — @weaponsforge/sendemail (trusted package code) Nodemailer Transporter SMTP client (OAuth2) Gmail SMTP · smtp.gmail.com :465 TLS · Google infrastructure (external, third-party) Gmail SMTP smtp.gmail.com :465 TLS Google OAuth2 · token refresh endpoint · Google infrastructure (external, third-party) Google OAuth2 token refresh endpoint CLI args dispatch html cmd HTML send() constructs validate transport init credentials creates SMTP :465 refresh token Consuming Node.js process — @weaponsforge/sendemail (trusted package code) Local secrets: .env / process.env (host-owned) Google infrastructure (external, third-party) Legend Backend Security External

Validation & Credentials

  • • EmailSchema, HtmlBuildSchema — types/email.schema.ts; TransportOath2Schema — types/transport.schema.ts
  • • Needs GOOGLE_USER_EMAIL, CLIENT_ID, CLIENT_SECRET, REFRESH_TOKEN
  • • Loaded via dotenv, or CLI --env <path>

Email Template & Build Modes

  • • EJS template at utils/templates/email.ejs, sanitized via sanitize-html
  • • SEA mode (IS_BUILD_SEA=true) imports the template statically; otherwise fs.readFile

Two Callers, One Path

  • • Library consumers call send() directly — no CLI layer involved
  • • The CLI is a thin Commander.js wrapper that calls the same send()

Limits & Distribution

  • • Max 20 recipients, enforced in EmailSender.sendEmail()
  • • Shipped as npm package, Docker image, and Windows SEA binary