Send Email (SMTP)
通过 SMTP 服务器发送邮件。
通过凭据描述的 SMTP 服务器发送一封邮件,并返回中继服务器的投递报告。
工作原理
- 解析配置。
connection_id、to、subject、text和html缺失时回退到输入 payload 中的同名键;connection_id、to和subject为必填。 - 解析凭据:
host、port(默认 587)、secure(默认 false)和from取自凭据配置;username(或user)和password(或pass)取自密钥。from默认为用户名。 - 打开 SMTP 传输,仅在存在用户名时进行认证。
- 使用
from、to、subject、text和html发送邮件,并以{ result }从out返回中继报告。
在工作流中
节点在工作流文件(draft_nodes[])中的写法,以及一次成功运行的 envelope。
{
"node_id": "node-send-alert",
"label": "Send alert email",
"operator_slug": "io.smtp",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"to": "ops@example.com",
"subject": "Order {{ $json.order_id }} requires review",
"text": "Order {{ $json.order_id }} exceeded the approval limit.",
"html": "<p>Order <strong>{{ $json.order_id }}</strong> exceeded the approval limit.</p>"
}
}{
"ok": true,
"data": {
"result": {
"accepted": [
"ops@example.com"
],
"rejected": [],
"envelope": {
"from": "no-reply@example.com",
"to": [
"ops@example.com"
]
},
"messageId": "<5f1c2a7e-8b1d-4a3e-9c0f-2d6e7b8a9c10@example.com>",
"response": "250 2.0.0 OK queued"
}
},
"port": "out"
}配置
-
connection_idstring 必填 -
SMTP 服务器的凭据。接受 `basic-auth`(用户名 + 密码 + 主机 + 端口)或 `connection-string`(smtp:// / smtps:// URI)类型的凭据。
-
tostring 必填 -
收件人邮箱(可多个)
-
subjectstring 必填 -
textstring 可选 -
纯文本正文
-
htmlstring 可选 -
HTML 正文
代码中的行为
除 schema 描述之外,实现代码对这些键的实际处理。
-
connection_id - 请使用在配置中包含
host、port、secure和from的basic-auth凭据。来自已保存凭据的connection-string密钥不会被解析。以{开头或包含://、@的值会被就地解析(JSON 对象或smtp://user:pass@host:portURI),仅用于本地测试。 -
html - 两者都设置时与
text一同发送;邮件客户端会显示 HTML 部分。
输出端口
out 默认 中继已接受邮件。result 为邮件库的发送报告:accepted、rejected、envelope、messageId、response,以及耗时字段。
数据
{
"result": {
"accepted": [
"ops@example.com"
],
"rejected": [],
"envelope": {
"from": "no-reply@example.com",
"to": [
"ops@example.com"
]
},
"messageId": "<5f1c2a7e-8b1d-4a3e-9c0f-2d6e7b8a9c10@example.com>",
"response": "250 2.0.0 OK queued"
}
}error 缺少必填字段、无法解析凭据,或连接、登录、发送失败。
数据
{
"error": "Invalid login: 535 5.7.8 Authentication credentials invalid"
}在表达式中
后续节点可通过 $("Send Email (SMTP)").item.json.<路径> 读取此节点输出中的内容(请把 Send Email (SMTP) 换成你的节点标签)。Editor 标记工作流编辑器在 Previous Nodes 中提示的路径(输出契约);Worker 标记 worker 实际通过 out 返回的路径,依据“端口”一节所示的输出。
| 表达式 | Editor | Worker |
|---|---|---|
$("Send Email (SMTP)").item.json.result发送信息 | ||
$("Send Email (SMTP)").item.json.result.accepted | — | |
$("Send Email (SMTP)").item.json.result.rejected | — | |
$("Send Email (SMTP)").item.json.result.envelope | — | |
$("Send Email (SMTP)").item.json.result.messageId | — | |
$("Send Email (SMTP)").item.json.result.response | — |
— Worker: worker 会返回它,但编辑器不会提示:请手动输入。对象内部的键可能取决于你的数据或配置(例如每个标签一个键)。
错误
| 消息 | 端口 | 原因与处理 |
|---|---|---|
to is required | error | 缺少收件人。to 可填写一个地址或以逗号分隔的多个地址。(connection_id is required 和 subject is required 对应其他必填字段。) |
Invalid login: <server response> | error | 服务器拒绝了用户名或密码。要求应用专用密码的服务商需要在凭据中保存该密码。 |
<TLS or connection error> | error | secure 与端口不匹配:465 端口请使用 secure: true,587 端口请使用 secure: false(会自动协商 STARTTLS)。 |
输入契约
-
connection_idstring 必填 -
tostring 必填 -
subjectstring 必填 -
textstring 可选 -
htmlstring 可选
输出契约
-
resultobject 可选 -
发送信息
契约(JSON Schema)
与编排器声明完全一致的定义。All 是完整的 *.definition.js;可与上方各节对照,找出文档与 schema 之间的差异。发布前可用它校验节点。
{
"slug": "io.smtp",
"name": "Send Email (SMTP)",
"category": "io",
"version": "1.0.0",
"description": "Send emails via SMTP server.",
"capabilities": [
"email",
"smtp",
"communication"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "SMTP Credential",
"description": "Credential for the SMTP server. Accepts credentials of type `basic-auth` (username + password + host + port) or `connection-string` (smtp:// / smtps:// URI).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"basic-auth",
"connection-string"
],
"types": [
"smtp"
]
}
},
"to": {
"type": "string",
"description": "Recipient email(s)"
},
"subject": {
"type": "string"
},
"text": {
"type": "string",
"description": "Text body"
},
"html": {
"type": "string",
"description": "HTML body"
}
},
"required": [
"connection_id",
"to",
"subject"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"to": {
"type": "string"
},
"subject": {
"type": "string"
},
"text": {
"type": "string"
},
"html": {
"type": "string"
}
},
"required": [
"connection_id",
"to",
"subject"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "Send info"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Sent",
"description": "Email accepted by relay",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Sending failed",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io"
],
"tags": [
"email",
"communication"
],
"is_stateful": false,
"publisher": {
"identity": "org_link_loom",
"profile": {
"name": "Link Loom",
"verified": true,
"url": "https://me.veripass.com/link-loom",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "SMTP Credential",
"description": "Credential for the SMTP server. Accepts credentials of type `basic-auth` (username + password + host + port) or `connection-string` (smtp:// / smtps:// URI).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"basic-auth",
"connection-string"
],
"types": [
"smtp"
]
}
},
"to": {
"type": "string",
"description": "Recipient email(s)"
},
"subject": {
"type": "string"
},
"text": {
"type": "string",
"description": "Text body"
},
"html": {
"type": "string",
"description": "HTML body"
}
},
"required": [
"connection_id",
"to",
"subject"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"to": {
"type": "string"
},
"subject": {
"type": "string"
},
"text": {
"type": "string"
},
"html": {
"type": "string"
}
},
"required": [
"connection_id",
"to",
"subject"
]
}{
"type": "object",
"properties": {
"result": {
"type": "object",
"description": "Send info"
}
}
}[
{
"port_id": "out",
"label": "Sent",
"description": "Email accepted by relay",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Sending failed",
"is_default": false,
"supports_condition": false
}
]执行
- 执行方式
async- 有状态
- 否
- 凭据
- 在服务器端根据
connection_id解析,密钥不会进入工作流。 - 能力
emailsmtpcommunication- 标签
emailcommunication
说明与限制
- 此节点不支持附件、
cc、bcc和replyTo。 out表示中继已接受邮件,并不代表已送达收件箱。不具备幂等性:每次运行都会发送一封新邮件;不会重试。
已对照编排器代码核实 · 31e874b · 2026-11-26