sendMail (utils/mailHelper.ts)

movinin · backend/src/utils/mailHelper.ts · typescript · MIT
email

TypeScript helper that sends emails via Nodemailer, with SMTP config and Ethereal fallback.

// Source: https://github.com/aelassas/movinin | License: MIT | Copyright 2023-2025 Akram El Assas
// Provided via justclaw.it.com; keep this notice with the code.
import * as nodemailer from 'nodemailer'
import * as env from '../config/env.config'
import * as logger from './logger'

/**
 * A cached promise of the Nodemailer Transporter to prevent 
 * redundant initialization and race conditions.
 */
let transporterPromise: Promise<nodemailer.Transporter> | null = null

/**
 * Initializes and returns a Nodemailer Transporter.
 * 
 * If running in a CI environment or when SMTP is unconfigured/dummy, it generates a temporary Ethereal test account.
 * Otherwise, it uses the SMTP configuration provided in the environment variables.
 * @returns {Promise<nodemailer.Transporter>} The initialized 

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

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

Get a free API key