@bernierllc/email-batch-sender

中文文档
0.4.9发布于 2026/11/05PROPRIETARYTypeScriptCommonJS近 30 天下载 1814

Batch email sending with concurrency control, rate limiting, retry strategies, and failure handling

原始使用文档
文档目录9 节
  1. Installation
  2. Usage
  3. Exports
  4. Provider Capability Support
  5. Capability Levels by Provider
  6. How It Works
  7. Degradation Behavior
  8. Override Options
  9. License

@bernierllc/email-batch-sender

Batch email sending with concurrency control, rate limiting, retry strategies, and failure handling. Provides a unified batch API across all email providers, using native provider batch endpoints where available and falling back to sequential sending otherwise.

Installation

npm install @bernierllc/email-batch-sender

Usage

import { createBatchSender } from '@bernierllc/email-batch-sender';

const sender = createBatchSender(emailSenderInstance, {
  concurrency: 5,
  rateLimit: { tokensPerInterval: 10, interval: 1000 },
  retry: { maxRetries: 3, backoffMs: 1000 },
});

const result = await sender.sendBatch([
  { to: '[email protected]', subject: 'Hello', html: '<p>Hi Alice</p>' },
  { to: '[email protected]', subject: 'Hello', html: '<p>Hi Bob</p>' },
]);

console.log(`Sent: ${result.succeeded} / ${result.total}`);

Exports

  • BatchSender -- main class for batch operations
  • createBatchSender() -- factory function
  • TokenBucketRateLimiter -- rate limiter used internally
  • BatchSenderError -- custom error class with error codes
  • Types: BatchSenderOptions, RateLimitOptions, BatchRetryOptions, BatchResult, BatchEmailResult, BatchProgress, BatchEmailInput

Provider Capability Support

This section documents how batch sending behaves across email providers, based on the canonical CAPABILITY_MATRIX in @bernierllc/email-manager.

Capability Levels by Provider

ProviderCapability LevelNotes
SendGridproviderNative batch API via personalizations; the provider handles batching server-side
MailgunproviderNative batch send via recipient variables
PostmarkproviderNative batch API endpoint (/email/batch)
SESproviderNative SendBulkEmail API
SMTPplatformNo native batch support; this package sends emails sequentially over the SMTP connection

How It Works

  • Provider-level (SendGrid, Mailgun, Postmark, SES): The email manager delegates to the provider's native batch endpoint. This package orchestrates the calls, handles rate limiting, and manages retries. The provider may process the batch as a single API call (SendGrid personalizations, Postmark batch endpoint) or as optimized bulk operations (SES SendBulkEmail).

  • Platform-level (SMTP): Since SMTP has no native batch support, this package sends emails sequentially over the SMTP connection. Concurrency, rate limiting, and retry logic are all handled at the platform level by this package.

Degradation Behavior

When used with a provider that lacks native batch support (currently only SMTP):

  • Strategy: sequential-batch
  • Behavior: Emails are sent one at a time over the SMTP connection, respecting the configured concurrency limit and rate limiter
  • Performance: Slower than native batch APIs; throughput depends on SMTP server response times and the configured concurrency/rate-limit settings
  • Reliability: Full retry support with configurable backoff; individual message failures do not block the rest of the batch

Override Options

The batch send capability is marked overridable: true for all providers with native support, meaning you can force platform-level sequential sending even when a native batch API is available. This can be useful for debugging or when provider batch endpoints have temporary issues.

// Force sequential sending regardless of provider
const sender = createBatchSender(emailSenderInstance, {
  forceSequential: true,
  concurrency: 3,
});

License

Copyright (c) 2025 Bernier LLC. All rights reserved.

This package is licensed to the client under a limited-use license. The client may use and modify this code only within the scope of the project it was delivered for. Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.

版本与发布记录

@bernierllc/email-batch-sender 共发布 19 个版本,首次发布于 2026/02/22;过去 12 个月发布了 19 个版本。

版本发布日期距今
0.4.9latest2026/11/053 天前
0.4.82026/10/2415 天前
0.4.72026/10/2316 天前
0.4.62026/10/1920 天前
0.4.52026/10/021 个月前
0.4.42026/10/021 个月前

关于 @bernierllc/email-batch-sender 的常见问题

@bernierllc/email-batch-sender 是什么?

Batch email sending with concurrency control, rate limiting, retry strategies, and failure handling

如何安装 @bernierllc/email-batch-sender?

在项目目录运行 npm install @bernierllc/email-batch-sender,或使用 pnpm add / yarn add / bun add。

@bernierllc/email-batch-sender 支持 TypeScript 吗?

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

@bernierllc/email-batch-sender 支持 ESM 还是 CommonJS?

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

@bernierllc/email-batch-sender 需要什么版本的 Node.js?

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

@bernierllc/email-batch-sender 可以商用吗?

@bernierllc/email-batch-sender 使用 PROPRIETARY 许可。声明的许可为 PROPRIETARY,请阅读许可原文确认使用条件。以上为概括,不构成法律意见,请以许可原文为准。

@bernierllc/email-batch-sender 的下载量有多少?

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

@bernierllc/email-batch-sender 还在维护吗?

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