邮件接收
x/receiveEmail组件:通过IMAP协议接收邮件。支持丰富的邮件搜索条件和动态模板变量。
# 配置
# 基础配置
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| server | string | IMAP服务器地址,支持${}变量替换 | 无 |
| port | int | IMAP端口 | 993 |
| username | string | 用户名,支持${}变量替换 | 无 |
| password | string | 密码,支持${}变量替换 | 无 |
| enableTls | bool | 是否启用TLS | true |
| connectTimeout | int | 连接超时时间(秒) | 10 |
# 搜索配置 (search)
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| folder | string | 邮件夹名称 | INBOX |
| since | string | 开始时间,格式: "2006-01-02",支持${}变量替换 | 无 |
| before | string | 结束时间,格式: "2006-01-02",支持${}变量替换 | 无 |
| lastDays | int | 最近N天内,优先于 since/before | 无 |
| from | string | 发件人地址或关键字,支持${}变量替换 | 无 |
| to | string | 收件人地址或关键字,支持${}变量替换 | 无 |
| subject | string | 主题关键字,支持${}变量替换 | 无 |
| unread | bool | 仅未读邮件 | false |
| limit | int | 最大返回数量,0表示不限制 | 无 |
# 获取配置 (fetch)
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| contentType | string | 获取内容类型: "full"(完整)、"headers"(仅头)、"body"(仅正文) | full |
| includeAttachments | bool | 是否获取附件 | false |
| maxAttachmentSizeMb | int | 最大附件大小(MB),超过则跳过,0表示不获取附件内容 | 0 |
| attachmentSavePath | string | 附件保存路径,支持${}变量替换,为空则嵌入到消息中 | 无 |
# 执行后操作配置 (postAction)
| 字段 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| action | string | 操作类型: "none"(无)、"markRead"(标记已读)、"delete"(删除)、"move"(移动) | none |
| targetFolder | string | 目标邮件夹,move操作时使用 | 无 |
# Relation Type
- Success: 执行成功,把消息发送到
Success链 - Failure: 执行失败,把消息发送到
Failure链
# 执行结果
执行成功后,邮件列表数据替换到msg.Data,格式如下:
{
"emails": [
{
"uid": 12345,
"messageId": "<abc123@mail.com>",
"subject": "邮件主题",
"from": {
"name": "发件人名称",
"address": "sender@example.com"
},
"to": [
{"name": "收件人名称", "address": "receiver@example.com"}
],
"cc": [],
"date": "2024-02-23T10:00:00Z",
"body": "纯文本正文内容",
"htmlBody": "<html>HTML正文</html>",
"headers": {
"X-Priority": "1"
},
"attachments": [
{
"filename": "document.pdf",
"contentType": "application/pdf",
"size": 12345,
"contentBase64": "..."
}
],
"flags": ["Seen", "Flagged"]
}
],
"total": 1
}
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
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
# 配置示例
# 示例1:基础配置
{
"id": "s1",
"type": "x/receiveEmail",
"name": "接收邮件",
"configuration": {
"server": "imap.gmail.com",
"port": 993,
"username": "user@gmail.com",
"password": "app_password",
"search": {
"folder": "INBOX",
"lastDays": 7,
"limit": 10
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# 示例2:使用模板变量
{
"id": "s2",
"type": "x/receiveEmail",
"name": "接收邮件-动态配置",
"configuration": {
"server": "${metadata.imapServer}",
"username": "${metadata.imapUser}",
"password": "${metadata.imapPassword}",
"search": {
"folder": "INBOX",
"since": "${metadata.sinceDate}",
"from": "${msg.senderEmail}",
"subject": "${msg.emailSubject}",
"unread": true,
"limit": 50
},
"fetch": {
"contentType": "full",
"includeAttachments": true,
"maxAttachmentSizeMb": 10
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 示例3:带附件保存和后置操作
{
"id": "s3",
"type": "x/receiveEmail",
"name": "接收并处理邮件",
"configuration": {
"server": "imap.gmail.com",
"port": 993,
"username": "user@gmail.com",
"password": "app_password",
"search": {
"folder": "INBOX",
"from": "@company.com",
"unread": true,
"limit": 20
},
"fetch": {
"contentType": "full",
"includeAttachments": true,
"maxAttachmentSizeMb": 20,
"attachmentSavePath": "/data/attachments/${metadata.tenantId}/"
},
"postAction": {
"action": "markRead"
}
}
}
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
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
# 示例4:移动邮件到归档文件夹
{
"id": "s4",
"type": "x/receiveEmail",
"name": "接收并归档邮件",
"configuration": {
"server": "imap.gmail.com",
"port": 993,
"username": "user@gmail.com",
"password": "app_password",
"search": {
"folder": "INBOX",
"lastDays": 30,
"limit": 100
},
"fetch": {
"contentType": "headers"
},
"postAction": {
"action": "move",
"targetFolder": "Archive"
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# 应用示例
应用示例参考:receiveEmail (opens new window)
{
"ruleChain": {
"id": "chain_receive_email",
"name": "邮件接收处理链",
"root": false,
"debugMode": false
},
"metadata": {
"nodes": [
{
"id": "s1",
"type": "x/receiveEmail",
"name": "接收未读邮件",
"debugMode": true,
"configuration": {
"server": "imap.gmail.com",
"port": 993,
"username": "${metadata.emailUser}",
"password": "${metadata.emailPassword}",
"search": {
"folder": "INBOX",
"unread": true,
"limit": 10
},
"fetch": {
"contentType": "full",
"includeAttachments": true,
"maxAttachmentSizeMb": 5
},
"postAction": {
"action": "markRead"
}
}
},
{
"id": "s2",
"type": "log",
"name": "记录日志",
"debugMode": true,
"configuration": {
"jsScript": "return '收到邮件: ' + JSON.stringify(msg);"
}
}
],
"connections": [
{
"fromId": "s1",
"toId": "s2",
"type": "Success"
}
]
}
}
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
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
# 注意事项
- Gmail配置:Gmail需要使用"应用专用密码"而非账户密码,并确保IMAP已启用
- 附件大小:大附件可能影响性能,建议设置
maxAttachmentSizeMb限制 - 模板变量:所有支持
${}语法的字段都可以使用metadata.key或msg.key进行动态替换 - 邮件夹名称:不同邮件服务商的邮件夹名称可能不同,如Gmail使用"Sent",而其他可能是"已发送"
在 GitHub 上编辑此页 (opens new window)
上次更新: 2026/02/24, 01:57:17