initMailer (auth/mailer.ts)

projx · features/auth/express/common/files/src/modules/auth/mailer.ts · typescript · MIT
email

Full-featured mailer module with SMTP init, template validation, variable escaping, dev fallback logging, and send helpers.

// Source: https://github.com/ukanhaupa/projx | License: MIT | Copyright 2026 Kanha Upadhyay
// Provided via justclaw.it.com; keep this notice with the code.
import nodemailer from 'nodemailer';

export const SMTP_PURPOSE = 'smtp';

const FRONTEND_URL = process.env.FRONTEND_URL ?? 'http://localhost:5173';

export interface SmtpConfig {
  host: string;
  port: number;
  secure: boolean;
  user: string;
  pass: string;
  from: string;
  [key: string]: unknown;
}

interface Logger {
  info: (obj: unknown, msg?: string) => void;
  warn: (obj: unknown, msg?: string) => void;
  error: (obj: unknown, msg?: string) => void;
}

let smtpConfig: SmtpConfig | null = null;
let transporter: ReturnType<typeof nodemailer.createTransport> | null = null;
let mailWarned = false;
let log: Logger = console;

e

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key