产品定价 立即试用
社区版
入门 文档 指南 安装 架构 API 常见问题

发送邮件

通过SMTP服务器发送邮件,支持可配置的认证和传输安全选项。 该节点期望接收由 “to email” 转换节点创建的 SEND_EMAIL 类型消息。

配置

Use system SMTP settings

控制使用平台级SMTP设置还是节点专用配置:

  • Enabled(默认)— 节点使用系统管理员配置的SMTP设置。启用后,其余SMTP配置字段隐藏且忽略。
  • Disabled — 节点使用节点配置中指定的自定义SMTP设置。允许不同邮件节点使用不同SMTP服务器或凭据。

SMTP settings

  • Protocol — 指定使用的邮件传输协议。可用选项:
    • SMTP(默认)— 标准SMTP协议
    • SMTPS — 基于SSL/TLS的SMTP
  • SMTP host — SMTP邮件服务器的主机名或IP地址。
  • SMTP port — SMTP服务器端口号。
  • Timeout (ms) — 套接字读取超时时间(毫秒)。默认10000(10秒)。若套接字读取超过此超时,节点失败并经 Failure 连接路由消息。

Security settings

  • Enable TLS — 控制是否为SMTP连接使用TLS加密。
    • Disabled(默认)— 连接使用明文SMTP,无加密。
    • Enabled — 连接在初始握手后使用STARTTLS升级为TLS加密。
  • TLS version — 当 Enable TLS 已启用时指定使用的TLS协议版本。默认TLSv1.2
  • Username — SMTP服务器认证的用户名。若SMTP服务器允许匿名访问则留空(生产环境不推荐)。
  • Password — SMTP服务器认证的密码。若SMTP服务器允许匿名访问则留空。
文档信息图标

注意:SMTP凭据可存储在 Secrets storage 以增强安全性。

Proxy settings

  • Enable proxy — 控制是否通过代理服务器路由SMTP流量。
    • Disabled(默认)— 直接连接SMTP服务器。
    • Enabled — 通过指定的代理服务器路由流量。启用后必须配置代理主机和端口。代理认证凭据可选。
  • Proxy host — 代理服务器的主机名或IP地址。
  • Proxy port — 代理服务器端口号。
  • Proxy user — 代理认证的可选用户名。若代理服务器无需认证则留空。
  • Proxy password — 代理认证的可选密码。若代理服务器无需认证则留空。
文档信息图标

注意:代理凭据可存储在 Secrets storage 以增强安全性。

Advanced settings

Force acknowledgement

强制确认机制由 ACTORS_RULE_EXTERNAL_NODE_FORCE_ACK 环境变量控制。当该变量设为 true 时,适用于包括本邮件节点在内的所有外部节点。

启用强制确认时的行为

  • 入站消息立即被确认并创建副本
  • 邮件发送操作异步执行
  • 发送操作完成后,消息副本加入队列供下一节点处理
  • 可避免慢速SMTP服务器或大附件导致的消息处理超时

禁用强制确认时(默认):

  • 原始入站消息在邮件发送操作完成前保持占用
  • 随后将消息传递至下一节点

JSON Schema

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "title": "TbSendEmailNodeConfiguration",
  "type": "object",
  "properties": {
    "useSystemSmtpSettings": {
      "type": "boolean",
      "description": "Whether to use platform-wide SMTP settings."
    },
    "smtpHost": {
      "type": "string",
      "description": "Hostname or IP address of the SMTP server."
    },
    "smtpPort": {
      "type": "integer",
      "minimum": 1,
      "maximum": 65535,
      "description": "Port number of the SMTP server."
    },
    "smtpProtocol": {
      "type": "string",
      "enum": ["smtp", "smtps"],
      "description": "Email transport protocol."
    },
    "timeout": {
      "type": "integer",
      "minimum": 1,
      "description": "Maximum time to wait for SMTP operations (milliseconds)."
    },
    "enableTls": {
      "type": "boolean",
      "description": "Whether to use STARTTLS encryption."
    },
    "tlsVersion": {
      "type": "string",
      "description": "TLS protocol version to use."
    },
    "enableProxy": {
      "type": "boolean",
      "description": "Whether to route traffic through a proxy server."
    },
    "proxyHost": {
      "type": "string",
      "description": "Hostname or IP address of the proxy server."
    },
    "proxyPort": {
      "type": "string",
      "description": "Port number of the proxy server."
    },
    "proxyUser": {
      "type": "string",
      "description": "Optional username for proxy authentication."
    },
    "proxyPassword": {
      "type": "string",
      "description": "Optional password for proxy authentication."
    },
    "username": {
      "type": "string",
      "description": "Username for SMTP server authentication."
    },
    "password": {
      "type": "string",
      "description": "Password for SMTP server authentication."
    }
  },
  "required": [
    "useSystemSmtpSettings"
  ],
  "additionalProperties": false
}

消息处理逻辑

该节点仅处理类型为 SEND_EMAIL 的消息。消息必须由“to email”转换节点创建,该节点将消息data转换为正确的邮件格式。

对每条入站消息,节点执行以下步骤:

  1. 消息类型验证 — 验证消息类型为 SEND_EMAIL。若不是,节点立即失败并附带错误信息,经 Failure 连接路由。

  2. 确认 — 若Force acknowledgement已启用,入站消息立即被确认并创建副本供后续处理。

  3. 异步发送邮件 — 异步发送邮件:
    • Use system SMTP settings已启用,由平台邮件服务使用系统配置发送邮件
    • Use system SMTP settings已禁用,使用节点专用配置发送邮件
  4. 结果路由
    • 成功时,原始消息(或启用强制确认时的消息副本)经 Success 连接转发
    • 失败时,在 error 键下将错误详情添加到消息metadata,消息经 Failure 连接转发
文档警告图标

重要:该节点期望接收由“to email”转换节点创建的消息。使用 Success 连接将“to email”节点连接至本节点。未正确邮件格式的直接消息将无法通过验证。

输出连接

  • Success
    • 邮件已通过SMTP服务器成功发送。
  • Failure
    • 消息类型不是 SEND_EMAIL
    • SMTP配置错误。
    • 邮件发送操作超时。
    • 处理过程中发生意外错误。

示例

示例1 — 使用系统SMTP设置发送告警邮件

温度监控系统在温度超过阈值时发送告警邮件。平台配置了Gmail账户的系统级SMTP设置。强制确认已禁用。

入站消息

Type: SEND_EMAIL

Data(由“to Email”转换节点准备):

1
2
3
4
5
{
  "to": "alerts@company.com",
  "subject": "High Temperature Alert",
  "body": "<html><body><h2>Temperature Alert</h2><p>Warehouse temperature has exceeded 30°C.</p><p>Current reading: 32.5°C</p></body></html>"
}

节点配置

1
2
3
4
5
6
7
8
9
10
{
  "useSystemSmtpSettings": true,
  "smtpHost": "localhost",
  "smtpPort": 25,
  "smtpProtocol": "smtp",
  "timeout": 10000,
  "enableTls": false,
  "tlsVersion": "TLSv1.2",
  "enableProxy": false
}

出站消息

出站消息与入站消息相同。因强制确认已禁用,邮件成功发送后原始入站消息传递至下一节点。

结果

使用平台的系统SMTP配置将邮件发送至 alerts@company.com。HTML正文在收件人邮件客户端中正确渲染。随后消息经 Success 连接路由。