@storyshelf/notify-email
@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.
Install
Section titled “Install”npm i @storyshelf/notify-emailpnpm add @storyshelf/notify-emailyarn add @storyshelf/notify-emailThe SMTP preset needs the optional nodemailer peer; the log and HTTP presets do not:
npm i nodemailerpnpm add nodemaileryarn add nodemailer- npm package — install tarballs and version history.
- Source on GitHub — package directory on
main.
Configure
Section titled “Configure”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 }),});Presets
Section titled “Presets”| Preset | Use for |
|---|---|
smtpPreset | A corporate relay, Postfix, or SES over SMTP. smtpPresetFromEnv reads the settings from environment variables. |
mailpitPreset | Local development against Mailpit (localhost:1025). |
httpPreset | A Resend- or Postmark-style JSON HTTP endpoint. |
logPreset | Tests 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";