Docs/Guides

Email

@veap/mail provides a transport-independent MailMessage contract and a sendMail() facade. The package includes a console provider for development and a Nodemailer provider for…

2 min read

@veap/mail provides a transport-independent MailMessage contract and a sendMail() facade. The package includes a console provider for development and a Nodemailer provider for SMTP-compatible delivery, plus helpers for common auth notifications.

Register the provider#

ts
import { Application } from "@veap/kernel";
import { MailServiceProvider } from "@veap/mail";

export const app = Application.configure()
  .use(MailServiceProvider)
  .create();

Send an email#

ts
import { sendMail } from "@veap/mail";

await sendMail({
  to: "person@example.com",
  subject: "Welcome",
  text: "Thanks for creating an account.",
  html: "<p>Thanks for creating an account.</p>",
});

MailMessage supports to, subject, text, html, from, cc, bcc, replyTo, attachments, priority, and custom headers. Recipients may be address strings or objects with name and address.

Configuration#

The package documents MAIL_TRANSPORT, MAIL_SERVICE, MAIL_USERNAME, MAIL_PASSWORD, GOOGLE_SMTP_APP_USERNAME, GOOGLE_SMTP_APP_PASSWORD, and MAIL_FROM_ADDRESS. When no credentials or explicit transport are set, the package README describes console delivery as the safe local default.

Do not rely on console delivery in production. Confirm the chosen transport at startup and send a monitored test message in each environment.

Custom transport#

The package exposes an IMailer contract and CUSTOM_MAILER token. A custom adapter should translate MailMessage to the external provider's native message format and implement delivery behavior without leaking provider-specific options into application services.

Attachments and HTML#

Only attach files the application is authorized to disclose. Sanitize user-provided content before embedding it in HTML. For inline images, use attachment content IDs and cid: references where supported by the transport. Avoid logging message bodies or attachment contents.

veap
Preparing0%