LogoRobo.js
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

NameTypeDescription
attachments?MailAttachment[]Attachments appended to the message.
from?MailPartyOptional sender override (falls back to emails.from).
headers?Record<string, string>Custom headers such as X-Priority.
html?stringRich HTML body; ignored when templateId is provided.
subjectstringSubject line, required for inline templates.
tags?string[]Tracking tags supported by providers like Resend or Postmark.
templateId?stringProvider template identifier (SendGrid dynamic templates, Postmark, etc.).
text?stringPlain-text fallback body.
toMailPartyRecipient 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 }]
}

On this page