@astram/messaging

中文文档
0.1.22发布于 2026/11/06MITTypeScriptCommonJS近 30 天下载 3416

Astram framework — email delivery adapters (SMTP over nodemailer; Brevo, SendGrid and Mailgun over plain fetch) behind the @astram/core EmailProvider port. Bounded sends, one jittered retry on transient failures, sanitised errors that never carry a creden

原始使用文档

@astram/messaging

Email delivery adapters for the Astram framework (G-010). Each one implements the EmailProvider port from @astram/core.

Apps normally do not import this package. Install it next to @astram/guard and set ShieldModule.forRoot({ emailSender: 'env' }). Guard reads and checks the EMAIL_* / SMTP_* / provider env at boot, loads this package and calls createEmailProvider with the result. Guard also bounds and audits every send.

Providers

EMAIL_PROVIDERTransportProbe (sends nothing)
smtpnodemailer (loaded only when SMTP is configured); TLS starttls, implicit or none (loopback only); certificates always verifiedverify(): connect, STARTTLS, AUTH, QUIT
brevoPOST /v3/smtp/email, plain fetchGET /v3/account
sendgridPOST /v3/mail/send, plain fetchGET /v3/scopes (must include mail.send)
mailgunPOST /v3/{domain}/messages, plain fetch, US or EU hostGET /v3/domains/{domain}

Behaviour

  • Every send and probe is bounded by timeoutMs (default 10 000, max 30 000). At the bound the call is abandoned and its socket or request is aborted.
  • A transient failure (network, HTTP 429/5xx, SMTP 4xx) is retried once, with jittered backoff, only if the bound has room. A permanent failure or a timeout is never retried.
  • HTTP providers use https only and do not follow redirects.
  • Failures are MessageDeliveryError (transient | permanent | timeout). Their message is built from the provider name, the class and the HTTP status only. It never includes a credential, a recipient, the message, or the provider's response body.
  • An unusable config (non-https baseUrl, a timeout out of range, CR/LF in a header value) is refused with a plain Error that names the field, never its value.

@astram/core is a peer dependency, so an app installs exactly one copy.

版本与发布记录

@astram/messaging 共发布 23 个版本,首次发布于 2026/10/15;过去 12 个月发布了 23 个版本。

版本发布日期距今
0.1.22latest2026/11/061 天前
0.1.212026/11/044 天前
0.1.202026/11/034 天前
0.1.192026/11/034 天前
0.1.182026/11/016 天前
0.1.172026/10/317 天前

关于 @astram/messaging 的常见问题

@astram/messaging 是什么?

Astram framework — email delivery adapters (SMTP over nodemailer; Brevo, SendGrid and Mailgun over plain fetch) behind the @astram/core EmailProvider port. Bounded sends, one jittered retry on transient failures, sanitised errors that never carry a creden

如何安装 @astram/messaging?

在项目目录运行 npm install @astram/messaging,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@astram/core(^1.19.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@astram/messaging 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@astram/messaging 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@astram/messaging 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.3.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@astram/messaging 可以商用吗?

@astram/messaging 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@astram/messaging 的下载量有多少?

根据 npm 官方下载统计,@astram/messaging 在 2026/10/07 – 2026/11/05 这 30 天内被下载 3,416 次,日均约 114 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@astram/messaging 还在维护吗?

最新版本 0.1.22 发布于 2026/11/06(1 天前);至今共发布 23 个版本,其中过去 12 个月发布了 23 个;首次发布于 2026/10/15。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。