Skip to content

@storyshelf/notify-email

View as Markdown

@storyshelf/notify-email is the email transport for StoryShelf. One sender serves notification channels and, optionally, authentication mail such as invites and password resets. It is the only package that owns nodemailer.

Terminal window
npm i @storyshelf/notify-email

The SMTP preset needs the optional nodemailer peer; the log and HTTP presets do not:

Terminal window
npm i nodemailer
import { createShelfApp } from "@storyshelf/app";
import { createShelfAuth } from "@storyshelf/auth";
import { createEmailNotifier, smtpPreset } from "@storyshelf/notify-email";
const sender = smtpPreset({ host: "mail.example.com", port: 587, from: "shelf@example.com" });
const app = createShelfApp({
database,
storage,
notifications: { notifiers: [createEmailNotifier(sender, { from: "shelf@example.com" })] },
// Optional: invites and password resets share the same transport.
// auth: createShelfAuth({ db, secret, baseURL, emailSender: sender }),
});
PresetUse for
smtpPresetA corporate relay, Postfix, or SES over SMTP. smtpPresetFromEnv reads the settings from environment variables.
mailpitPresetLocal development against Mailpit (localhost:1025).
httpPresetA Resend- or Postmark-style JSON HTTP endpoint.
logPresetTests and unconfigured setups — messages are written to the log.

See Notifications for how email channels, subscriptions, and auth mail fit together.

Each preset is importable on its own:

Each preset is importable on its own (root aggregates all):

import { smtpPreset, smtpPresetFromEnv } from "@storyshelf/notify-email/smtp";
import { mailpitPreset } from "@storyshelf/notify-email/mailpit";
import { logPreset } from "@storyshelf/notify-email/log";
import { httpPreset } from "@storyshelf/notify-email/http";
import { createEmailNotifier } from "@storyshelf/notify-email/email";