Packages@robojs/auth
MailMessage
Type Alias: MailMessage
type MailMessage = {
attachments: MailAttachment[];
from: MailParty;
headers: Record<string, string>;
html: string;
subject: string;
tags: string[];
templateId: string;
text: string;
to: MailParty;
variables: Record<string, unknown>;
};Message contract understood by mail adapters and builders. Includes support
for inline HTML/text or provider-managed templates via templateId.
Type declaration
| Name | Type | Description |
|---|---|---|
attachments? | MailAttachment[] | Attachments appended to the message. |
from? | MailParty | Optional sender override (falls back to emails.from). |
headers? | Record<string, string> | Custom headers such as X-Priority. |
html? | string | Rich HTML body; ignored when templateId is provided. |
subject | string | Subject line, required for inline templates. |
tags? | string[] | Tracking tags supported by providers like Resend or Postmark. |
templateId? | string | Provider template identifier (SendGrid dynamic templates, Postmark, etc.). |
text? | string | Plain-text fallback body. |
to | MailParty | Recipient address. |
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 }]
}