Type Alias: MailMessage
type MailMessage: object;
Message contract understood by mail adapters and builders. Includes support
for inline HTML/text or provider-managed templates via templateId.
Type declaration
attachments?
optional attachments: MailAttachment[];
Attachments appended to the message.
from?
optional from: MailParty;
Optional sender override (falls back to emails.from).
headers?
optional headers: Record<string, string>;
Custom headers such as X-Priority.
html?
optional html: string;
Rich HTML body; ignored when templateId is provided.
subject
subject: string;
Subject line, required for inline templates.
tags?
optional tags: string[];
Tracking tags supported by providers like Resend or Postmark.
templateId?
optional templateId: string;
Provider template identifier (SendGrid dynamic templates, Postmark, etc.).
text?
optional text: string;
Plain-text fallback body.
to
to: MailParty;
Recipient address.
variables?
optional variables: Record<string, unknown>;
Variables consumed by provider templates.
Examples
{ to: user.email!, subject: 'Welcome', html: '<p>Hello!</p>', text: 'Hello!' }
{
to: user.email!,
subject: '',
templateId: 'd-reset',
variables: { userName: user.name, link: ctx.links?.resetPassword }
}
{
to: user.email!,
subject: 'Invoice',
html: '<p>Attached invoice</p>',
attachments: [{ filename: 'invoice.pdf', content: pdfBuffer }]
}