@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 结果, 主题标记,体标,一个短时间窗口,和一个代码长度. 在缺失或重复的认证证据上检索失败, 没有候选人,候选人/体积过大,没有匹配,不止一个 匹配信件,或不止一个带有标记的代码发生.
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: ["[email protected]"],
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;只有时间的关联性更弱.
电子邮件代码仍为无记名值,不耐打网球. 更喜欢奥奥特, 在上游服务时,钥匙,或提供者-当地授权的行动 支持他们.
安装
bun add @absolutejs/email
邮件
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: "[email protected]",
});
微软图形
import {
createMicrosoftGraphEmailClient,
microsoftMessagesToNormalized,
} from "@absolutejs/email";
const client = createMicrosoftGraphEmailClient({ accessToken });
const { messages, cursor } = await client.listDelta();
const normalized = microsoftMessagesToNormalized(messages, {
accountEmail: "[email protected]",
});
入境邮件( 续)
重新发送 email.received webhook 只携带元数据; 主体和标题
来自接收的API. resolveResendInboundEmail 两者并存,返回
中性供应商 InboundEmailMessage。 。 。 . stripQuotedReply 隔离
发件人自己的单词(引用历史、签名、移动签注和展望)
标题块已删除),所以一个主机可以在回复上采取行动或预览.
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 地图
import { fetchImapMessages } from "@absolutejs/email";
const result = await fetchImapMessages({
accountEmail: "[email protected]",
auth: { pass: appPassword, user: "[email protected]" },
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 之前, 必须先通过批准并使用可持久执行的输入门 .