Records outgoing mail instead of sending it.
-
connect(): Promise<void>
Establishes any backing connection/client. No-op for stateless providers.
-
disconnect(): Promise<void>
Releases any backing connection/client. No-op for stateless providers.
-
isHealthy(): Promise<boolean>
M70c: a log provider never touches a network, so it is always reachable (M47).
-
isReady(): boolean
Reports whether the provider is ready to send.
-
messages(): readonly OutgoingMail[]
Every message recorded by this provider, in send order.
-
send(message: OutgoingMail): Promise<void>
Records and logs a message.
Mailer backed by a pluggable provider and a template engine.
-
isHealthy(): Promise<boolean | undefined>
Reports whether the backing provider's transport is reachable right now.
-
send(message: MailMessage): Promise<void>
Sends an email, resolving
fromfrom the message or the configured default. -
sendTemplate(): Promise<void>template: string,message: Omit<MailMessage, "html" | "text">,data: Readonly<Record<string, unknown>>
Renders a named template and sends the result. The
subjectis taken verbatim frommessage; the template supplies thehtml/textbodies.
SendGrid provider over fetch.
-
connect(): Promise<void>
Establishes any backing connection/client. No-op for stateless providers.
-
disconnect(): Promise<void>
Releases any backing connection/client. No-op for stateless providers.
-
isHealthy(): Promise<boolean>
M70c: a
GET /v3/scopesthrough the existingIMailHttpseam. 2xx means the key is valid; 401 means the API reached us (so the backend is reachable even though the key is wrong); any other status or a network failure means unreachable. -
isReady(): boolean
Reports whether the provider is ready to send.
-
send(message: OutgoingMail): Promise<void>
Sends a message via the SendGrid v3 API.
AWS SESv2 provider.
-
connect(): Promise<void>
Establishes any backing connection/client. No-op for stateless providers.
-
disconnect(): Promise<void>
Releases any backing connection/client. No-op for stateless providers.
-
isHealthy: () => Promise<boolean>
M70c: present only when the client exposes
isHealthy?()(the real adapter issuesGetAccount); its absence is unknown reachability, notfalse. -
isReady(): boolean
Reports whether the provider is ready to send.
-
send(message: OutgoingMail): Promise<void>
Sends a message via SES.
SMTP provider over nodemailer.
-
connect(): Promise<void>
Establishes any backing connection/client. No-op for stateless providers.
-
disconnect(): Promise<void>
Releases any backing connection/client. No-op for stateless providers.
-
isHealthy: () => Promise<boolean>
M70c: present only when the transport exposes
verify(); its absence is unknown reachability, notfalse(a minimal injected fake has not told us the server is dead). -
isReady(): boolean
Reports whether the provider is ready to send.
-
send(message: OutgoingMail): Promise<void>
Sends a message over SMTP.
A registry of named body templates with {{ variable }} interpolation.
-
has(name: string): boolean
Reports whether a template is registered.
-
render(): RenderedTemplatename: string,data: Readonly<Record<string, unknown>>
Renders a template's bodies with
data.
Adapts the nodemailer module to a transport facade. Pure — unit-tested with
a fake module; the real module is supplied on the lazy path by
loadNodemailerModule.
Adapts the AWS SESv2 SDK module to the facade. Pure — unit-tested with a fake
module; the real module is supplied on the lazy path by loadSesModule.
Builds the provider adapter for the configured backend.
Escapes the five HTML-significant characters so interpolated user data cannot inject markup into an HTML body.
Lazily imports nodemailer. Only exercised on the lazy path.
Lazily imports the AWS SESv2 SDK. Only exercised on the lazy path.
Creates the MailPlugin.
Maps an OutgoingMail to nodemailer's message fields.
Maps an OutgoingMail to a SendGrid v3 request body.
Maps an OutgoingMail to a SendEmailCommand input.
Validates that an injected object matches ISesClient.
Validates that an injected object matches ISmtpTransport.
Email sender.
-
isHealthy(): Promise<boolean | undefined>
Reports whether the mail transport is REACHABLE right now, distinct from whether the mailer was constructed. Optional: a mailer whose transport exposes no side-effect-free probe omits it, and so does an implementation that does not answer the question at all.
-
send(message: MailMessage): Promise<void>
Sends an email.
-
sendTemplate(): Promise<void>template: string,message: Omit<MailMessage, "html" | "text">,data: Readonly<Record<string, unknown>>
Renders a named template and sends the result.
Structural shape of an AWS SESv2 client facade (injected or SDK-adapted). The
plugin never hard-depends on @aws-sdk/client-sesv2.
-
isHealthy(): Promise<boolean>
M70c: reports whether the SES account is reachable — the real adapter issues
GetAccount. Optional so a minimal injected fake still type-checks; a client that omits it is unknown, notfalse. -
sendEmail(message: OutgoingMail): Promise<void>
Sends one message via SES.
Structural shape of a nodemailer transport. The plugin never hard-depends on
nodemailer; inject this shape, or SmtpProvider lazily loads the
package and adapts it to this facade.
-
sendMail(mail: { from: string; to: string; subject: string; text?: string; html?: string; cc?: string; bcc?: string; }): Promise<unknown>
Sends one message.
-
verify(): Promise<unknown>
M70c: verifies the SMTP connection. nodemailer's real transport exposes this; a minimal injected fake may omit it, in which case the provider reports unknown reachability rather than
false.
Options for LogProvider.
-
logger: ILogger
Logger to write each send to (typically
ctx.logger). -
sink: (message: OutgoingMail) => void
Called with each sent message — a read-back seam for tests/hooks.
An outgoing email message.
-
bcc: readonly string[]
Blind-carbon-copy recipients.
-
cc: readonly string[]
Carbon-copy recipients.
-
from: string
Sender address; omitted to use the provider default.
-
html: string
HTML body.
-
subject: string
Subject line.
-
text: string
Plain-text body.
-
to: string | readonly string[]
Recipient address(es).
Options for the MailPlugin factory.
-
defaults: { from?: string; }
Message defaults applied when a message omits the field.
-
options: MailProviderOptions
Provider-specific options.
-
provider: MailProviderType
Provider backend. Defaults to
'log'. -
templates: Record<string, MailTemplate>
Named body templates available to
sendTemplate.
Provider-specific options. Fields are consumed only by the matching provider;
unrelated fields are ignored (mirrors SecretsProviderOptions).
-
accessKeyId: string
(
ses) AWS access key id for the lazily-loaded client. -
apiKey: string
(
sendgrid) SendGrid API key sent as a Bearer token. -
auth: { user: string; pass: string; }
(
smtp) SMTP auth credentials. -
client: ISesClient
(
ses) Injected client facade; bypasses the lazy SDK import. -
endpoint: string
(
sendgrid) API endpoint. Defaulthttps://api.sendgrid.com/v3/mail/send. -
host: string
(
smtp) SMTP server host. -
http: IMailHttp
(
sendgrid) Injectedfetch-shaped function; defaults to globalfetch. -
port: number
(
smtp) SMTP server port. Default587. -
region: string
(
ses) AWS region for the lazily-loaded client. -
secretAccessKey: string
(
ses) AWS secret access key for the lazily-loaded client. -
secure: boolean
(
smtp) Use an implicit TLS connection. Defaultfalse. -
sink: (message: OutgoingMail) => void
(
log) Called with each sent message — a read-back seam for tests/hooks. -
transport: ISmtpTransport
(
smtp) Injected transport facade; bypasses the lazynodemailerimport.
Options for MailService.
-
defaultFrom: string
Default sender used when a message omits
from. -
probeTiming: ProbeTiming
Monotonic clock and timers used to cache and bound
MailService.isHealthy.
A named body template. At least one of html/text must be present.
-
html: string
HTML body template with
{{ variable }}placeholders (values escaped). -
text: string
Plain-text body template with
{{ variable }}placeholders (raw).
The subset of nodemailer the adapter uses.
A rendered template body. Only present bodies are returned.
Options for SendGridProvider.
-
apiKey: string | undefined
SendGrid API key sent as a Bearer token.
-
endpoint: string | undefined
API endpoint. Default
https://api.sendgrid.com/v3/mail/send. -
http: IMailHttp | undefined
Injected
fetch-shaped function; defaults to globalfetch.
Options for SesProvider.
-
accessKeyId: string | undefined
AWS access key id for the lazily-loaded client.
-
client: ISesClient | undefined
Injected client facade; bypasses the lazy SDK import.
-
region: string | undefined
AWS region for the lazily-loaded client.
-
secretAccessKey: string | undefined
AWS secret access key for the lazily-loaded client.
The subset of the AWS SESv2 SDK the adapter uses.
Options for SmtpProvider.
-
auth: { user: string; pass: string; } | undefined
SMTP auth credentials.
-
host: string | undefined
SMTP server host.
-
port: number | undefined
SMTP server port. Default
587. -
secure: boolean | undefined
Use an implicit TLS connection. Default
false. -
transport: ISmtpTransport | undefined
Injected transport facade; bypasses the lazy
nodemailerimport.
A fetch-shaped function used by SendGridProvider so it stays
runtime-agnostic and testable.
Supported mail provider backends.
An outgoing email whose sender has already been resolved by
MailService (from the message or the configured default). This is
the shape every MailProvider receives — from is never absent.
Usage
import * as Email_plugin_with_log__SMTP___nodemailer____AWS_SES__v2___and_SendGrid_providers_plus_a_zero_dependency_____variable_____template_engine___Exports_the_plugin_factory__service__provider_implementations__structural_client_facades__the_template_engine__and_option_types_ from "mail-plugin/src/index.ts";