@antelopejs/nodemailer
羚羊JS节点邮件模块通过SMTP发送电子邮件界面的信息 节点。 。 。 .
接口
| 接口 | 文档 |
|---|---|
@antelopejs/interface-email | 电子邮件 |
模块执行 Send, (中文(简体) ), SendBatch, (中文(简体) ), SendTemplate,以及 GetCapabilities它支持内置模板、附件, replyTo以及优先事项。 它不支持提供者托管的模板,所以 SendTemplate 带有模板 ID 返回 a NOT_SUPPORTED 错误.
安装
ajs project modules add @antelopejs/nodemailer
模块没有默认配置 。 添加一个 config 在项目开始前设置块.
配置
import { defineConfig } from "@antelopejs/interface-core/config";
export default defineConfig({
name: "my-project",
modules: {
nodemailer: {
source: {
type: "package",
package: "@antelopejs/nodemailer",
version: "^0.0.7",
},
config: {
host: "smtp.example.com",
port: 587,
secure: false,
auth: { user: "smtp-user", pass: "smtp-password" },
defaults: { from: "[email protected]" },
},
},
},
envOverrides: {
SMTP_PASSWORD: "modules.nodemailer.config.auth.pass",
},
});
| 密钥 | 说明 |
|---|---|
host | SMTP主机. 要求,除非 ethereal 实值 true。 。 。 . |
port | SMTP端口,作为数字. 要求,除非 ethereal 实值 true。 。 。 . |
secure | 从连接开始使用 TLS 。 默认为 true 第465和465号港口 false 否则. |
requireTLS | 需要STARTLS系统. 默认为 true 何时 auth 设置和 secure 决定: false设置为 false 以允许清晰文本认证. |
auth | 可选 SMTP 证书, { user, pass }。两者在设定时都必须是非空的. |
defaults.from | 当信件没有时使用发送器 from。 。 。 . |
ethereal | 设定为 true 开发中发送临时 爱丽丝 账户. |
与 ethereal: true,模块忽略了其他密钥,在启动时创建一个账户,登录其地址并将其作为默认发送者. 每个发送的信件都会在您可以读取的地方登录一个预览 URL.
快开始
在发送电子邮件的模块中,添加接口:
pnpm add @antelopejs/interface-email
import { Send } from "@antelopejs/interface-email";
const result = await Send({
to: "[email protected]",
subject: "Welcome",
text: "Your account is ready.",
html: "<p>Your account is ready.</p>",
});
result.success 告诉您 SMTP 服务器是否接受信件 。 如果失败了, result.error 保存错误代码和消息.
文档
兼容性
| 软件包 | 支助 | 测试过 |
|---|---|---|
@antelopejs/interface-core | >=0.2.4 <1.0.0 | 0.2.4 |
@antelopejs/interface-email | >=0.1.0 <0.2.0 | 0.1.0 |
捐款
使用节点版本 .nvmrc 和 pnpm 版本在 packageManager 领域 package.json数字 :
pnpm install
pnpm dev # run the playground/ project with an Ethereal account
pnpm lint
pnpm format:check
pnpm knip
pnpm test # build, then ajs module test
读取 捐款准则 在打开拉出请求之前.