# @absolutejs/email 中文文档

规范地址：https://npmcn.com/package/%40absolutejs/email/

版本：0\.11\.0
npm 元数据更新时间：2026-11-06T23:53:23.778Z
中文译文更新时间：2026-11-06T09:13:18.434Z
软件包许可：BSL-1\.1

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40absolutejs/email
原文对照：https://npmcn.com/package/%40absolutejs/email/?lang=original
项目主页：https://github.com/absolutejs/email
源码仓库：https://github.com/absolutejs/email

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：270 kB，28 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：3 个
- 首次发布：2026-06-17T00:02:08.213Z
- 最新版本发布：2026-11-06T23:53:23.641Z
- 近 30 天下载量：3642（2026-10-05 至 2026-11-03，npm 官方下载统计）
- 已发布版本数：22（近 12 个月 22 个）

## 中文简介

为绝对JS提供中性电子邮件同步并输入适配器:Gmail,Microsoft Graph,IMAP,和Resend Inbound.

## 安装

```sh
npm install @absolutejs/email
```

也可以使用：`pnpm add @absolutejs/email`、`yarn add @absolutejs/email`、`bun add @absolutejs/email`

## README

# @absolutejs/电子邮件

Gmail适配器还可以在Inbox,Spam, 回收站和其他标签 `findGmailMessagePlacement`。主机应用程序 拥有金丝雀列表,邮箱证明,警示政策,并坚持不懈.

为绝对JS应用程序提供中性电子邮件同步适配器.

这个软件包拥有提供机理:

-   Gmail REST 同步 , 请检查url=值 (帮助), `users.watch`,和Pub/Sub有效载荷分析
-   微软 Graph 消息三角洲同步和订阅通知解析
-   为自定义的邮箱提供商提供的 IMAP 超過 TLS
-   正常化消息形状,主机应用程序可以持续,计分,过滤或丰富

主机应用程序拥有产品政策:

-   用户同意和隐私控制
-   证书存储
-   具体商业相关性评分
-   数据库持久性
-   队列调度和 UI

## 工具封闭的验证代码

`@absolutejs/email/verification` 提供了决定性的 Gmail, Microsoft Graph, 和 IMAP 检查外加 Agent Exchange 源适配器的严格解析器. 这是一个 library API,故意从软件包的模型显示工具中遗漏.

主要核查入口是Gmail和Microsoft Graph的浏览器安全. 导入只使用服务器的 IMAP 查询 `@absolutejs/email/verification/imap` 这样 浏览器捆绑不会在节点 TLS 中拉出 `imapflow`。 。 。 .

配置文件将邮箱查询绑定为 HTTPS 的出处、 提供者名称、 发送者 地址、可信赖的 RFC 8601 认证服务、 对齐的 DMARC 结果, 主题标记,体标,一个短时间窗口,和一个代码长度. 在缺失或重复的认证证据上检索失败, 没有候选人,候选人/体积过大,没有匹配,不止一个 匹配信件,或不止一个带有标记的代码发生.

```ts
import {
  createGmailVerificationMessageLookup,
  retrieveEmailVerificationCode,
} from "@absolutejs/email/verification";

const result = await retrieveEmailVerificationCode(
  createGmailVerificationMessageLookup({ accountEmail, client: gmail }),
  {
    accountEmail,
    expectedOrigin: "https://accounts.example.com",
    notBefore: new Date(requestCreatedAt),
    notAfter: new Date(requestExpiresAt),
    profile: {
      bodyMarkers: ["verification code"],
      id: "accounts-example-six-digit-v1",
      origins: ["https://accounts.example.com"],
      providers: ["gmail"],
      senderAddresses: ["security@example.com"],
      senderAuthentication: {
        allowedHeaderFromDomains: ["example.com"],
        trustedAuthservIds: ["mx.mailbox.example"],
      },
      subjectIncludesAny: ["sign in"],
    },
  },
);

// Pass result.bytes directly to a trusted sink or E2EE envelope. Do not stringify
// it, log it, add it to a prompt, or return it from an agent tool.
result.bytes.fill(0);
```

`trustedAuthservIds` 这是针对部署的。 只配置自动服务器 插入到您信箱提供者信任的边界内; 绝不复制 无信任 `Authentication-Results` 从上游更远处取出头条 。 所需数额 DMARC 通行证必须与可见发件人域和 允许列表域。 对于交叉代理请求,也会通过一个无法预测的请求 请求通过 `requiredBodyText`;只有时间的关联性更弱.

电子邮件代码仍为无记名值,不耐打网球. 更喜欢奥奥特, 在上游服务时,钥匙,或提供者-当地授权的行动 支持他们.

## 安装

```bash
bun add @absolutejs/email
```

## 邮件

```ts
import {
  createGmailClient,
  gmailMessagesToNormalized,
  parseGmailPubSubWebhook,
} from "@absolutejs/email";

const client = createGmailClient({ accessToken });
const { messages, cursor } = await client.listHistory({ cursor: historyId });
const normalized = await gmailMessagesToNormalized(client, messages, {
  accountEmail: "member@example.com",
});
```

## 微软图形

```ts
import {
  createMicrosoftGraphEmailClient,
  microsoftMessagesToNormalized,
} from "@absolutejs/email";

const client = createMicrosoftGraphEmailClient({ accessToken });
const { messages, cursor } = await client.listDelta();
const normalized = microsoftMessagesToNormalized(messages, {
  accountEmail: "member@example.com",
});
```

## 入境邮件( 续)

重新发送 `email.received` webhook 只携带元数据; 主体和标题 来自接收的API. `resolveResendInboundEmail` 两者并存,返回 中性供应商 `InboundEmailMessage`。 。 。 . `stripQuotedReply` 隔离 发件人自己的单词(引用历史、签名、移动签注和展望) 标题块已删除),所以一个主机可以在回复上采取行动或预览.

```ts
import { resolveResendInboundEmail, stripQuotedReply } from "@absolutejs/email";

const email = await resolveResendInboundEmail(resendApiKey, webhookBody);
if (email) {
  const alias = email.to.find((to) => to.address.startsWith("r+"));
  const words = stripQuotedReply(email.text, { maxLength: 4000 });
  // route by alias, dedupe on email.emailId, thread on email.inReplyTo
}
```

## IMAP 地图

```ts
import { fetchImapMessages } from "@absolutejs/email";

const result = await fetchImapMessages({
  accountEmail: "member@example.com",
  auth: { pass: appPassword, user: "member@example.com" },
  host: "imap.fastmail.com",
  port: 993,
  secure: true,
});
```

核查配置文件可选择采用 `codeLayout: "standalone-after-marker"` 页:1 在介绍文本后在自己的行上显示代码的信息。 准确 已配置的正文标记必须在512个字符内的代码之前. 多个代码 或匹配消息仍然含糊不清并关闭。 发件人认证, 接受者、服务来源、科目、时间窗口和候选人限额仍然适用. Gmail和Microsoft HTML 正常化为这种布局保留了块边界. 默认布局仍然是紧接所配置的标记后的代码.

## 主机控制 Gmail 发送

`sendGmailMessage(message, { fetch, signal })` 发送一个包含最多五个附件( 共10 MB) 的纯文本 MIME 消息 。 捆绑 `fetch` (b) 包件从未获得证书或批准. `buildOutgoingMime` 可供检查。 提供稳定的 RFC 消息ID,以及两者 `threadId` 财务报告和审定财务报表 `inReplyTo` 用于答复.

发送是一次尝试. `EmailSendError.outcome` 明确拒绝与 `unknown`; 绝不自动重试未知的发件. Gmail的Message-ID是用于调和,而不是一能保证. 主机在引用此 API 之前, 必须先通过批准并使用可持久执行的输入门 .

## 常见问题

### @absolutejs/email 是什么？

为绝对JS提供中性电子邮件同步并输入适配器:Gmail,Microsoft Graph,IMAP,和Resend Inbound\.

### 如何安装 @absolutejs/email？

在项目目录运行 npm install @absolutejs/email，或使用 pnpm add / yarn add / bun add。

### @absolutejs/email 支持 TypeScript 吗？

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

### @absolutejs/email 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @absolutejs/email 可以商用吗？

@absolutejs/email 使用 BSL-1\.1 许可。声明的许可为 BSL-1\.1，请阅读许可原文确认使用条件。以上为概括，不构成法律意见，请以许可原文为准。

### @absolutejs/email 的下载量有多少？

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

### @absolutejs/email 还在维护吗？

最新版本 0\.11\.0 发布于 2026/11/07（今天）；至今共发布 22 个版本，其中过去 12 个月发布了 22 个；首次发布于 2026/06/17。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

