Nodemailer (Email)
The default notifier. Two modes: Ethereal (automatic test inbox, no config) or real SMTP (Gmail, Resend, SendGrid, etc.).
import { NodemailerNotifier, createAuth } from "guardo";
// No smtp config → auto-creates an Ethereal test account
const auth = createAuth({
jwt: { secret: "..." },
notifier: new NodemailerNotifier(),
});
// Outputs a preview URL to the console after sendingWithout a buildHtml/buildText override, guardo sends a polished default
email template. The default subject is "Your verification code".
EmailNotifierOptions
| Field | Type | Default | Description |
|---|---|---|---|
smtp | SmtpConfig? | - | SMTP credentials. Omit to use Ethereal in dev. |
from | string? | smtp user → Ethereal address | The “From” address. |
subject | string? | "Your verification code" | Email subject line. |
buildHtml | (code, expiresInSeconds?) => string | built-in template | Custom HTML body. |
buildText | (code, expiresInSeconds?) => string | auto-generated | Custom plain-text body. |
SmtpConfig: { host: string; port?: number; secure?: boolean; user: string; pass: string }
(port defaults to 587, secure to false).
⚠️
If Ethereal is unreachable (no internet / sandboxed CI), the notifier falls back to printing the OTP to the console so local flows don’t break.